diff --git a/.simplecov b/.simplecov index a019f5a93..6183af459 100644 --- a/.simplecov +++ b/.simplecov @@ -2,7 +2,7 @@ SimpleCov.start do enable_coverage :branch - minimum_coverage line: 100, branch: 98.44 + minimum_coverage line: 100, branch: 98.57 add_filter '/spec/' add_filter '/vendor/bundle/' end diff --git a/lib/rubocop/rspec/config_formatter.rb b/lib/rubocop/rspec/config_formatter.rb index 50858e109..72abb8c68 100644 --- a/lib/rubocop/rspec/config_formatter.rb +++ b/lib/rubocop/rspec/config_formatter.rb @@ -7,7 +7,7 @@ module RSpec # Builds a YAML config file from two config hashes class ConfigFormatter EXTENSION_ROOT_DEPARTMENT = %r{^(RSpec/)}.freeze - AMENDMENTS = %(Metrics/BlockLength) + AMENDMENTS = %w[Metrics/BlockLength].freeze COP_DOC_BASE_URL = 'https://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/' def initialize(config, descriptions) @@ -17,8 +17,8 @@ def initialize(config, descriptions) def dump YAML.dump(unified_config) - .gsub(EXTENSION_ROOT_DEPARTMENT, "\n\\1") - .gsub(*AMENDMENTS, "\n\\0") + .gsub(EXTENSION_ROOT_DEPARTMENT, "\n\\0") + .gsub(Regexp.union(AMENDMENTS), "\n\\0") .gsub(/^(\s+)- /, '\1 - ') .gsub('"~"', '~') end @@ -27,8 +27,6 @@ def dump def unified_config cops.each_with_object(config.dup) do |cop, unified| - next if AMENDMENTS.include?(cop) - replace_nil(unified[cop]) unified[cop].merge!(descriptions.fetch(cop)) unified[cop]['Reference'] = reference(cop) diff --git a/spec/rubocop/rspec/config_formatter_spec.rb b/spec/rubocop/rspec/config_formatter_spec.rb index 2eef01294..a713057b4 100644 --- a/spec/rubocop/rspec/config_formatter_spec.rb +++ b/spec/rubocop/rspec/config_formatter_spec.rb @@ -8,6 +8,12 @@ 'AllCops' => { 'Setting' => 'forty two' }, + 'Metrics/BlockLength' => { + 'Exclude' => [ + '**/*_spec.rb', + '**/spec/**/*' + ] + }, 'RSpec/Foo' => { 'Config' => 2, 'Enabled' => true @@ -45,6 +51,11 @@ AllCops: Setting: forty two + Metrics/BlockLength: + Exclude: + - "**/*_spec.rb" + - "**/spec/**/*" + RSpec/Foo: Config: 2 Enabled: true