Skip to content

Commit

Permalink
Update test/config_test.rb
Browse files Browse the repository at this point in the history
Co-authored-by: Sam Bostock <sambostock@users.noreply.github.com>
  • Loading branch information
volmer and sambostock committed Apr 4, 2022
1 parent 0065d2a commit fa8ffe7
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions test/config_test.rb
Expand Up @@ -34,25 +34,26 @@ def test_config_is_unchanged
def test_config_has_no_redundant_entries
config = RuboCop::ConfigLoader.load_file("rubocop.yml")
default_config = RuboCop::ConfigLoader.default_configuration
redundant_config = Hash.new { |hash, key| hash[key] = {} }

# This entry is not a cop.
config.delete("inherit_mode")

config.each do |cop_name, cop_config|
default_cop_config = default_config.fetch(cop_name)
cop_config.each do |key, value|
error_message = <<~ERROR
Error: #{cop_name} was configured with the same value as the default
RuboCop configuration.
default_value = default_cop_config[key]
redundant_config[cop_name][key] = value if value == default_value
end
end

#{cop_name}:
#{key}: #{value}
flunk(<<~ERROR.chomp) unless redundant_config.empty?
Error: The following config values are the same as the default Rubocop configuration:
Please remove the configuration as it is unnecessary.
ERROR
#{redundant_config.to_yaml.sub(/\A---\n/, "").chomp}
refute_equal(default_cop_config[key], value, error_message)
end
end
Please remove these entries from the configuration, as they are unnecessary.
ERROR
end
end
end

0 comments on commit fa8ffe7

Please sign in to comment.