Skip to content

Commit

Permalink
Merge pull request #373 from Shopify/remove-redundant
Browse files Browse the repository at this point in the history
Remove redundant configuration keys
  • Loading branch information
volmer committed Apr 4, 2022
2 parents d499e4e + cb5f388 commit 677c98e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
12 changes: 0 additions & 12 deletions rubocop.yml
Expand Up @@ -24,9 +24,6 @@ Layout/ArgumentAlignment:
Layout/CaseIndentation:
EnforcedStyle: end

Layout/EmptyLineAfterGuardClause:
Enabled: true

Layout/EndAlignment:
EnforcedStyleAlignWith: variable

Expand Down Expand Up @@ -370,9 +367,6 @@ Style/AndOr:
Style/ArgumentsForwarding:
Enabled: false

Style/AsciiComments:
Enabled: false

Style/BisectedAttrAccessor:
Enabled: false

Expand Down Expand Up @@ -439,9 +433,6 @@ Style/EvalWithLocation:
Style/ExpandPathArguments:
Enabled: false

Style/ExplicitBlockArgument:
Enabled: true

Style/ExponentialNotation:
Enabled: false

Expand All @@ -463,9 +454,6 @@ Style/FrozenStringLiteralComment:
literals will become the default in a future Ruby version, and we want to make
sure we''re ready.'

Style/GlobalStdStream:
Enabled: true

Style/GuardClause:
Enabled: false

Expand Down
27 changes: 27 additions & 0 deletions test/config_test.rb
Expand Up @@ -30,4 +30,31 @@ def test_config_is_unchanged
assert(diff.empty?, error_message)
end
end

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|
default_value = default_cop_config[key]
redundant_config[cop_name][key] = value if value == default_value
end
end

error_message = <<~ERROR
Error: The following config values are the same as the default Rubocop configuration:
#{redundant_config.to_yaml.delete_prefix("---\n")}
Please remove these entries from the configuration, as they are unnecessary.
ERROR

assert(redundant_config.empty?, error_message)
end
end

0 comments on commit 677c98e

Please sign in to comment.