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 f74a385
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test/config_test.rb
Expand Up @@ -34,25 +34,27 @@ 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}
error_message = <<~ERROR
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.delete_prefix("---\n")}
refute_equal(default_cop_config[key], value, error_message)
end
end
Please remove these entries from the configuration, as they are unnecessary.
ERROR

assert redundant_config.empty?, error_message
end
end

0 comments on commit f74a385

Please sign in to comment.