From fa8ffe7b72702946e806e59c481ac7c23996d5f9 Mon Sep 17 00:00:00 2001 From: Volmer Campos Soares Date: Mon, 4 Apr 2022 09:18:26 -0400 Subject: [PATCH] Update test/config_test.rb Co-authored-by: Sam Bostock --- test/config_test.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/test/config_test.rb b/test/config_test.rb index 125cedae..ab40b034 100644 --- a/test/config_test.rb +++ b/test/config_test.rb @@ -34,6 +34,7 @@ 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") @@ -41,18 +42,18 @@ def test_config_has_no_redundant_entries 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