From 695169dcb27c531a252f9ef19b52aea58605a28b Mon Sep 17 00:00:00 2001 From: Daniel Colson Date: Fri, 24 Jun 2022 12:34:17 -0400 Subject: [PATCH] Delete legacy config Maintaining a separate "edge" config and "legacy" config probably served us well [back around the time we were migrating to rubocop 0.68](https://github.com/github/rubocop-github/commit/d533765dcdb9a05f6016a65502d5433f44d19996), but it's not working well for us anymore. Things changed often before rubocop 1.0, and there are versions out there that don't work perfectly with either of these configs (see https://github.com/github/rubocop-github/pull/86, for example). This commit sets a version constraint for rubocop ">= 1.0.0" and deletes the `*_deprecated.yml` files that only worked with rubocop < 0.68. With the deprecated files deleted, it also consolidates the remaining files into default.yml and rails.yml. --- Gemfile.lock | 4 +- README.md | 27 +-- config/_default_shared.yml | 333 --------------------------------- config/_rails_shared.yml | 124 ------------- config/default.yml | 336 +++++++++++++++++++++++++++++++++- config/default_deprecated.yml | 4 - config/default_edge.yml | 4 - config/rails.yml | 129 ++++++++++++- config/rails_deprecated.yml | 7 - config/rails_edge.yml | 4 - rubocop-github.gemspec | 2 +- 11 files changed, 469 insertions(+), 505 deletions(-) delete mode 100644 config/_default_shared.yml delete mode 100644 config/_rails_shared.yml delete mode 100644 config/default_deprecated.yml delete mode 100644 config/default_edge.yml delete mode 100644 config/rails_deprecated.yml delete mode 100644 config/rails_edge.yml diff --git a/Gemfile.lock b/Gemfile.lock index 37ac99a..556dcbe 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,7 +2,7 @@ PATH remote: . specs: rubocop-github (0.17.0) - rubocop + rubocop (>= 1.0.0) rubocop-performance rubocop-rails @@ -48,7 +48,7 @@ GEM rake (13.0.6) regexp_parser (2.2.0) rexml (3.2.5) - rubocop (1.25.0) + rubocop (1.25.1) parallel (~> 1.10) parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) diff --git a/README.md b/README.md index 99bad2a..328ed2b 100644 --- a/README.md +++ b/README.md @@ -4,28 +4,6 @@ This repository provides recommended RuboCop configuration and additional Cops f ## Usage -Rubocop 0.68 removed performance cops and 0.72 removed Rails cops. However, upgrading `rubocop-github` without modification will almost definitely create very many new offenses. The current version of this gem exposes the "legacy" configuration under `config/default.yml` and `config/rails.yml` which should be used *if and only if* the version of rubocop is locked to `< 0.68` in your project (which it should be unless you `bundle update rubocop`). It also exposes an "edge" configuration under `config/default_edge.yml` and `config/rails_edge.yml` so that the changes can be tested without introducing breaking changes. - -### Legacy usage - -**Gemfile** - -``` ruby -gem "rubocop", "< 0.68" -gem "rubocop-github" -``` - -**.rubocop.yml** - -``` yaml -inherit_gem: - rubocop-github: - - config/default.yml - - config/rails.yml -``` - -### Edge usage - **Gemfile** ``` ruby @@ -43,6 +21,11 @@ inherit_gem: - config/rails_edge.yml ``` +### Legacy usage + +If you are using a rubocop version < 1.0.0, you can use rubocop-github version +0.16.2 (see the README from that version for more details). + ## Testing `bundle install` diff --git a/config/_default_shared.yml b/config/_default_shared.yml deleted file mode 100644 index 4f9e334..0000000 --- a/config/_default_shared.yml +++ /dev/null @@ -1,333 +0,0 @@ -require: - - rubocop/cop/github - - rubocop-performance - -# These cops are compatible across supported versions of rubocop - -Bundler/DuplicatedGem: - Enabled: true - -Bundler/OrderedGems: - Enabled: true - -GitHub/InsecureHashAlgorithm: - Enabled: true - -Layout/BlockAlignment: - Enabled: true - -Layout/BlockEndNewline: - Enabled: true - -Layout/ConditionPosition: - Enabled: true - -Layout/DefEndAlignment: - Enabled: true - -Layout/EndAlignment: - Enabled: false - -Layout/EndOfLine: - Enabled: true - -Layout/IndentationStyle: - Enabled: true - EnforcedStyle: spaces - IndentationWidth: 2 - -Layout/IndentationWidth: - Enabled: true - Width: 2 - -Layout/InitialIndentation: - Enabled: true - -Layout/LineLength: - Enabled: false - -Layout/SpaceAfterColon: - Enabled: true - -Layout/SpaceAfterComma: - Enabled: true - -Layout/SpaceAfterMethodName: - Enabled: true - -Layout/SpaceAfterNot: - Enabled: true - -Layout/SpaceAfterSemicolon: - Enabled: true - -Layout/SpaceAroundBlockParameters: - Enabled: true - -Layout/SpaceAroundEqualsInParameterDefault: - Enabled: true - -Layout/SpaceBeforeBlockBraces: - Enabled: true - -Layout/SpaceInsideArrayLiteralBrackets: - Enabled: true - EnforcedStyle: no_space - -Layout/SpaceInsideArrayPercentLiteral: - Enabled: true - -Layout/SpaceInsideBlockBraces: - Enabled: true - -Layout/SpaceInsideParens: - Enabled: true - -Layout/SpaceInsideRangeLiteral: - Enabled: true - -Layout/SpaceInsideReferenceBrackets: - Enabled: true - -Layout/TrailingEmptyLines: - Enabled: true - -Layout/TrailingWhitespace: - Enabled: true - -Lint/CircularArgumentReference: - Enabled: true - -Lint/Debugger: - Enabled: true - -Lint/DeprecatedClassMethods: - Enabled: true - -Lint/DuplicateMethods: - Enabled: true - -Lint/DuplicateHashKey: - Enabled: true - -Lint/EachWithObjectArgument: - Enabled: true - -Lint/ElseLayout: - Enabled: true - -Lint/EmptyEnsure: - Enabled: true - -Lint/EmptyInterpolation: - Enabled: true - -Lint/EnsureReturn: - Enabled: true - -Lint/FlipFlop: - Enabled: true - -Lint/FloatOutOfRange: - Enabled: true - -Lint/FormatParameterMismatch: - Enabled: true - -Lint/LiteralAsCondition: - Enabled: true - -Lint/LiteralInInterpolation: - Enabled: true - -Lint/Loop: - Enabled: true - -Lint/NextWithoutAccumulator: - Enabled: true - -Lint/RandOne: - Enabled: true - -Lint/RequireParentheses: - Enabled: true - -Lint/RescueException: - Enabled: true - -Lint/RedundantStringCoercion: - Enabled: true - -Lint/UnderscorePrefixedVariableName: - Enabled: true - -Lint/RedundantCopDisableDirective: - Enabled: true - -Lint/RedundantSplatExpansion: - Enabled: true - -Lint/UnreachableCode: - Enabled: true - -Lint/BinaryOperatorWithIdenticalOperands: - Enabled: true - -Lint/UselessSetterCall: - Enabled: true - -Lint/Void: - Enabled: true - -Metrics/AbcSize: - Enabled: false - -Metrics/BlockLength: - Enabled: false - -Metrics/BlockNesting: - Enabled: false - -Metrics/ClassLength: - Enabled: false - -Metrics/CyclomaticComplexity: - Enabled: false - -Metrics/MethodLength: - Enabled: false - -Metrics/ModuleLength: - Enabled: false - -Metrics/ParameterLists: - Enabled: false - -Metrics/PerceivedComplexity: - Enabled: false - -Naming/AsciiIdentifiers: - Enabled: true - -Naming/ClassAndModuleCamelCase: - Enabled: true - -Naming/FileName: - Enabled: true - -Naming/MethodName: - Enabled: true - -Performance/CaseWhenSplat: - Enabled: false - -Performance/Count: - Enabled: true - -Performance/Detect: - Enabled: true - -Performance/DoubleStartEndWith: - Enabled: true - -Performance/EndWith: - Enabled: true - -Performance/FlatMap: - Enabled: true - -Performance/RangeInclude: - Enabled: false - -Performance/RedundantMatch: - Enabled: false - -Performance/RedundantMerge: - Enabled: true - MaxKeyValuePairs: 1 - -Performance/ReverseEach: - Enabled: true - -Performance/Size: - Enabled: true - -Performance/StartWith: - Enabled: true - -Security/Eval: - Enabled: true - -Style/ArrayJoin: - Enabled: true - -Style/BeginBlock: - Enabled: true - -Style/BlockComments: - Enabled: true - -Style/CaseEquality: - Enabled: true - -Style/CharacterLiteral: - Enabled: true - -Style/ClassMethods: - Enabled: true - -Style/Copyright: - Enabled: false - -Style/DefWithParentheses: - Enabled: true - -Style/EndBlock: - Enabled: true - -Style/For: - Enabled: true - -Style/FrozenStringLiteralComment: - Enabled: true - -Style/HashSyntax: - Enabled: true - EnforcedStyle: ruby19_no_mixed_keys - -Style/LambdaCall: - Enabled: true - -Style/MethodCallWithoutArgsParentheses: - Enabled: true - -Style/MethodDefParentheses: - Enabled: true - -Style/MultilineIfThen: - Enabled: true - -Style/NilComparison: - Enabled: true - -Style/Not: - Enabled: true - -Style/OneLineConditional: - Enabled: true - -Style/RedundantSortBy: - Enabled: true - -Style/Sample: - Enabled: true - -Style/StabbyLambdaParentheses: - Enabled: true - -Style/Strip: - Enabled: true - -Style/StringLiterals: - Enabled: true - EnforcedStyle: double_quotes diff --git a/config/_rails_shared.yml b/config/_rails_shared.yml deleted file mode 100644 index db030d0..0000000 --- a/config/_rails_shared.yml +++ /dev/null @@ -1,124 +0,0 @@ -Rails/OutputSafety: - Enabled: true - -Rails/PluralizationGrammar: - Enabled: true - -Rails/RequestReferer: - Enabled: true - EnforcedStyle: referrer - -Rails/ScopeArgs: - Enabled: true - -Rails/UniqBeforePluck: - Enabled: true - -GitHub/RailsApplicationRecord: - Enabled: true - -GitHub/RailsControllerRenderActionSymbol: - Enabled: true - Include: - - 'app/controllers/**/*.rb' - -GitHub/RailsControllerRenderLiteral: - Enabled: true - StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md - Include: - - 'app/controllers/**/*.rb' - -GitHub/RailsControllerRenderPathsExist: - Enabled: true - ViewPath: - - 'app/views' - Include: - - 'app/controllers/**/*.rb' - -GitHub/RailsControllerRenderShorthand: - Enabled: true - StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-shorthand.md - Include: - - 'app/controllers/**/*.rb' - -GitHub/RailsRenderInline: - Enabled: true - StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-inline.md - Include: - - 'app/controllers/**/*.rb' - - 'app/helpers/**/*.rb' - - 'app/view_models/**/*.rb' - - 'app/views/**/*.erb' - -GitHub/RailsRenderObjectCollection: - Enabled: false - -GitHub/RailsViewRenderLiteral: - Enabled: true - StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md - Include: - - 'app/helpers/**/*.rb' - - 'app/view_models/**/*.rb' - - 'app/views/**/*.erb' - -GitHub/RailsViewRenderPathsExist: - Enabled: true - ViewPath: - - 'app/views' - Include: - - 'app/helpers/**/*.rb' - - 'app/view_models/**/*.rb' - - 'app/views/**/*.erb' - -GitHub/RailsViewRenderShorthand: - Enabled: true - Include: - - 'app/helpers/**/*.rb' - - 'app/view_models/**/*.rb' - - 'app/views/**/*.erb' - -# Exclude Rails ERB files from incompatible cops - -Layout/BlockAlignment: - Exclude: - - 'app/views/**/*.erb' - -Style/For: - Exclude: - - 'app/views/**/*.erb' - -Style/OneLineConditional: - Exclude: - - 'app/views/**/*.erb' - -Style/Semicolon: - Exclude: - - 'app/views/**/*.erb' - -Layout/SpaceInsideParens: - Exclude: - - 'app/views/**/*.erb' - -Style/StringLiterals: - Exclude: - - 'app/views/**/*.erb' - -Layout/TrailingEmptyLines: - Exclude: - - 'app/views/**/*.erb' - -Layout/TrailingWhitespace: - Exclude: - - 'app/views/**/*.erb' - -Layout/IndentationWidth: - Exclude: - - 'app/views/**/*.erb' - -Layout/InitialIndentation: - Exclude: - - 'app/views/**/*.erb' - -Lint/UselessAccessModifier: - ContextCreatingMethods: - - concerning diff --git a/config/default.yml b/config/default.yml index 4729768..67af72a 100644 --- a/config/default.yml +++ b/config/default.yml @@ -1,2 +1,334 @@ -# Inherit from default_deprecated until 1.0 -inherit_from: default_deprecated.yml +require: + - rubocop/cop/github + - rubocop-performance + +AllCops: + DisabledByDefault: true + +Bundler/DuplicatedGem: + Enabled: true + +Bundler/OrderedGems: + Enabled: true + +GitHub/InsecureHashAlgorithm: + Enabled: true + +Layout/BlockAlignment: + Enabled: true + +Layout/BlockEndNewline: + Enabled: true + +Layout/ConditionPosition: + Enabled: true + +Layout/DefEndAlignment: + Enabled: true + +Layout/EndAlignment: + Enabled: false + +Layout/EndOfLine: + Enabled: true + +Layout/IndentationStyle: + Enabled: true + EnforcedStyle: spaces + IndentationWidth: 2 + +Layout/IndentationWidth: + Enabled: true + Width: 2 + +Layout/InitialIndentation: + Enabled: true + +Layout/LineLength: + Enabled: false + +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAfterMethodName: + Enabled: true + +Layout/SpaceAfterNot: + Enabled: true + +Layout/SpaceAfterSemicolon: + Enabled: true + +Layout/SpaceAroundBlockParameters: + Enabled: true + +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true + +Layout/SpaceBeforeBlockBraces: + Enabled: true + +Layout/SpaceInsideArrayLiteralBrackets: + Enabled: true + EnforcedStyle: no_space + +Layout/SpaceInsideArrayPercentLiteral: + Enabled: true + +Layout/SpaceInsideBlockBraces: + Enabled: true + +Layout/SpaceInsideParens: + Enabled: true + +Layout/SpaceInsideRangeLiteral: + Enabled: true + +Layout/SpaceInsideReferenceBrackets: + Enabled: true + +Layout/TrailingEmptyLines: + Enabled: true + +Layout/TrailingWhitespace: + Enabled: true + +Lint/CircularArgumentReference: + Enabled: true + +Lint/Debugger: + Enabled: true + +Lint/DeprecatedClassMethods: + Enabled: true + +Lint/DuplicateMethods: + Enabled: true + +Lint/DuplicateHashKey: + Enabled: true + +Lint/EachWithObjectArgument: + Enabled: true + +Lint/ElseLayout: + Enabled: true + +Lint/EmptyEnsure: + Enabled: true + +Lint/EmptyInterpolation: + Enabled: true + +Lint/EnsureReturn: + Enabled: true + +Lint/FlipFlop: + Enabled: true + +Lint/FloatOutOfRange: + Enabled: true + +Lint/FormatParameterMismatch: + Enabled: true + +Lint/LiteralAsCondition: + Enabled: true + +Lint/LiteralInInterpolation: + Enabled: true + +Lint/Loop: + Enabled: true + +Lint/NextWithoutAccumulator: + Enabled: true + +Lint/RandOne: + Enabled: true + +Lint/RequireParentheses: + Enabled: true + +Lint/RescueException: + Enabled: true + +Lint/RedundantStringCoercion: + Enabled: true + +Lint/UnderscorePrefixedVariableName: + Enabled: true + +Lint/RedundantCopDisableDirective: + Enabled: true + +Lint/RedundantSplatExpansion: + Enabled: true + +Lint/UnreachableCode: + Enabled: true + +Lint/BinaryOperatorWithIdenticalOperands: + Enabled: true + +Lint/UselessSetterCall: + Enabled: true + +Lint/Void: + Enabled: true + +Metrics/AbcSize: + Enabled: false + +Metrics/BlockLength: + Enabled: false + +Metrics/BlockNesting: + Enabled: false + +Metrics/ClassLength: + Enabled: false + +Metrics/CyclomaticComplexity: + Enabled: false + +Metrics/MethodLength: + Enabled: false + +Metrics/ModuleLength: + Enabled: false + +Metrics/ParameterLists: + Enabled: false + +Metrics/PerceivedComplexity: + Enabled: false + +Naming/AsciiIdentifiers: + Enabled: true + +Naming/ClassAndModuleCamelCase: + Enabled: true + +Naming/FileName: + Enabled: true + +Naming/MethodName: + Enabled: true + +Performance/CaseWhenSplat: + Enabled: false + +Performance/Count: + Enabled: true + +Performance/Detect: + Enabled: true + +Performance/DoubleStartEndWith: + Enabled: true + +Performance/EndWith: + Enabled: true + +Performance/FlatMap: + Enabled: true + +Performance/RangeInclude: + Enabled: false + +Performance/RedundantMatch: + Enabled: false + +Performance/RedundantMerge: + Enabled: true + MaxKeyValuePairs: 1 + +Performance/ReverseEach: + Enabled: true + +Performance/Size: + Enabled: true + +Performance/StartWith: + Enabled: true + +Security/Eval: + Enabled: true + +Style/ArrayJoin: + Enabled: true + +Style/BeginBlock: + Enabled: true + +Style/BlockComments: + Enabled: true + +Style/CaseEquality: + Enabled: true + +Style/CharacterLiteral: + Enabled: true + +Style/ClassMethods: + Enabled: true + +Style/Copyright: + Enabled: false + +Style/DefWithParentheses: + Enabled: true + +Style/EndBlock: + Enabled: true + +Style/For: + Enabled: true + +Style/FrozenStringLiteralComment: + Enabled: true + +Style/HashSyntax: + Enabled: true + EnforcedStyle: ruby19_no_mixed_keys + +Style/LambdaCall: + Enabled: true + +Style/MethodCallWithoutArgsParentheses: + Enabled: true + +Style/MethodDefParentheses: + Enabled: true + +Style/MultilineIfThen: + Enabled: true + +Style/NilComparison: + Enabled: true + +Style/Not: + Enabled: true + +Style/OneLineConditional: + Enabled: true + +Style/RedundantSortBy: + Enabled: true + +Style/Sample: + Enabled: true + +Style/StabbyLambdaParentheses: + Enabled: true + +Style/Strip: + Enabled: true + +Style/StringLiterals: + Enabled: true + EnforcedStyle: double_quotes diff --git a/config/default_deprecated.yml b/config/default_deprecated.yml deleted file mode 100644 index f6e45de..0000000 --- a/config/default_deprecated.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: _default_shared.yml - -AllCops: - DisabledByDefault: true diff --git a/config/default_edge.yml b/config/default_edge.yml deleted file mode 100644 index 6eb850c..0000000 --- a/config/default_edge.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: _default_shared.yml - -require: - - rubocop-performance diff --git a/config/rails.yml b/config/rails.yml index b669a25..ab16d61 100644 --- a/config/rails.yml +++ b/config/rails.yml @@ -1,2 +1,127 @@ -# Inherit from rails_deprecated until 1.0 -inherit_from: rails_deprecated.yml +require: + - rubocop-rails + +Rails/OutputSafety: + Enabled: true + +Rails/PluralizationGrammar: + Enabled: true + +Rails/RequestReferer: + Enabled: true + EnforcedStyle: referrer + +Rails/ScopeArgs: + Enabled: true + +Rails/UniqBeforePluck: + Enabled: true + +GitHub/RailsApplicationRecord: + Enabled: true + +GitHub/RailsControllerRenderActionSymbol: + Enabled: true + Include: + - 'app/controllers/**/*.rb' + +GitHub/RailsControllerRenderLiteral: + Enabled: true + StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md + Include: + - 'app/controllers/**/*.rb' + +GitHub/RailsControllerRenderPathsExist: + Enabled: true + ViewPath: + - 'app/views' + Include: + - 'app/controllers/**/*.rb' + +GitHub/RailsControllerRenderShorthand: + Enabled: true + StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-shorthand.md + Include: + - 'app/controllers/**/*.rb' + +GitHub/RailsRenderInline: + Enabled: true + StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-controller-render-inline.md + Include: + - 'app/controllers/**/*.rb' + - 'app/helpers/**/*.rb' + - 'app/view_models/**/*.rb' + - 'app/views/**/*.erb' + +GitHub/RailsRenderObjectCollection: + Enabled: false + +GitHub/RailsViewRenderLiteral: + Enabled: true + StyleGuide: https://github.com/github/rubocop-github/blob/master/guides/rails-render-literal.md + Include: + - 'app/helpers/**/*.rb' + - 'app/view_models/**/*.rb' + - 'app/views/**/*.erb' + +GitHub/RailsViewRenderPathsExist: + Enabled: true + ViewPath: + - 'app/views' + Include: + - 'app/helpers/**/*.rb' + - 'app/view_models/**/*.rb' + - 'app/views/**/*.erb' + +GitHub/RailsViewRenderShorthand: + Enabled: true + Include: + - 'app/helpers/**/*.rb' + - 'app/view_models/**/*.rb' + - 'app/views/**/*.erb' + +# Exclude Rails ERB files from incompatible cops + +Layout/BlockAlignment: + Exclude: + - 'app/views/**/*.erb' + +Style/For: + Exclude: + - 'app/views/**/*.erb' + +Style/OneLineConditional: + Exclude: + - 'app/views/**/*.erb' + +Style/Semicolon: + Exclude: + - 'app/views/**/*.erb' + +Layout/SpaceInsideParens: + Exclude: + - 'app/views/**/*.erb' + +Style/StringLiterals: + Exclude: + - 'app/views/**/*.erb' + +Layout/TrailingEmptyLines: + Exclude: + - 'app/views/**/*.erb' + +Layout/TrailingWhitespace: + Exclude: + - 'app/views/**/*.erb' + +Layout/IndentationWidth: + Exclude: + - 'app/views/**/*.erb' + +Layout/InitialIndentation: + Exclude: + - 'app/views/**/*.erb' + +Lint/UselessAccessModifier: + ContextCreatingMethods: + - concerning diff --git a/config/rails_deprecated.yml b/config/rails_deprecated.yml deleted file mode 100644 index 351af5f..0000000 --- a/config/rails_deprecated.yml +++ /dev/null @@ -1,7 +0,0 @@ -inherit_from: _rails_shared.yml - -Rails: - Enabled: true - -Rails/FindEach: - Enabled: false diff --git a/config/rails_edge.yml b/config/rails_edge.yml deleted file mode 100644 index 910a11a..0000000 --- a/config/rails_edge.yml +++ /dev/null @@ -1,4 +0,0 @@ -inherit_from: _rails_shared.yml - -require: - - rubocop-rails diff --git a/rubocop-github.gemspec b/rubocop-github.gemspec index 6de512f..2e98245 100644 --- a/rubocop-github.gemspec +++ b/rubocop-github.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |s| s.files = Dir["README.md", "STYLEGUIDE.md", "LICENSE", "config/*.yml", "lib/**/*.rb", "guides/*.md"] - s.add_dependency "rubocop" + s.add_dependency "rubocop", ">= 1.0.0" s.add_dependency "rubocop-performance" s.add_dependency "rubocop-rails"