Skip to content
Snippets Groups Projects
Unverified Commit 1bf3a4eb authored by Glenn Sarti's avatar Glenn Sarti Committed by GitHub
Browse files

Merge pull request #280 from glennsarti/pdk-1439-rubocop

(PDK-1439) Ignore GetText rubocop rules for the off profile
parents 50736c87 f6003753
No related branches found
No related tags found
No related merge requests found
......@@ -20,4 +20,6 @@
/tmp/
/vendor/
/convert_report.txt
# Rubocop profile builder temporary files
/rubocop/.rubocop.yml
/rubocop/.rubocop_todo.yml
......@@ -2,3 +2,4 @@ source 'https://rubygems.org'
gem 'rubocop', '= 0.49.1'
gem 'rubocop-rspec', '= 1.15.1'
gem 'rubocop-i18n', '= 1.2.0'
......@@ -2,6 +2,10 @@
:default_enabled_cops:
- Bundler/DuplicatedGem
- Bundler/OrderedGems
- GetText/DecorateFunctionMessage
- GetText/DecorateString
- GetText/DecorateStringFormattingUsingInterpolation
- GetText/DecorateStringFormattingUsingPercent
- Layout/AccessModifierIndentation
- Layout/AlignArray
- Layout/AlignHash
......
#!/usr/bin/env ruby
this_dir = __dir__
raise "This script must be run from the #{this_dir} directory" if this_dir != Dir.pwd
require 'yaml'
require 'rubocop/version'
File.delete('.rubocop.yml') if File.exist?('.rubocop.yml')
default_configs = YAML.load(`rubocop --show-cops --require rubocop-rspec`)
default_configs = YAML.load(`rubocop --show-cops --require rubocop-rspec --require rubocop-i18n`)
all_cops = default_configs.keys - [ 'AllCops', 'require' ]
default_enabled_cops = all_cops.find_all { |c| default_configs[c]['Enabled'] }
default_disabled_cops = all_cops - default_enabled_cops
$stderr.puts "Found #{default_enabled_cops.length} enabled, and #{default_disabled_cops.length} disabled cops in the default config."
# fetch config from current PDK
FileUtils.cp("../../pdk/.rubocop.yml", '.')
# fetch config from current PDK. Assume it's in the same directory as this repo.
FileUtils.cp(File.join('..', '..', 'pdk', '.rubocop.yml'), '.')
# stub out the included config to avoid rubocop complaints
File.open('.rubocop_todo.yml', 'w') do |f|
# nothing
......@@ -21,7 +24,7 @@ end
config = YAML.load(File.read('.rubocop.yml'))
configured_cops = YAML.load(`rubocop --show-cops`)
config_enabled_cops = all_cops.find_all { |c| configured_cops[c]['Enabled'] }
config_enabled_cops = all_cops.find_all { |c| configured_cops[c] && configured_cops[c]['Enabled'] }
config_disabled_cops = all_cops - config_enabled_cops
$stderr.puts "Found #{config_enabled_cops.length} enabled, and #{config_disabled_cops.length} disabled cops in the recommended config."
......@@ -48,7 +51,7 @@ force_disabled_cops = config_disabled_cops - default_disabled_cops
# end
# end
# end
File.open("defaults-#{RuboCop::Version.version}.yml", 'w') do |f|
File.open("defaults-#{RuboCop::Version.version}.yml", 'wb') do |f|
f.puts YAML.dump(default_enabled_cops: default_enabled_cops)
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment