Branch configs for incompatible changes

This commit is contained in:
Jacob Smith 2019-09-09 14:34:01 -04:00
Родитель 3b29ee8e47
Коммит d533765dcd
10 изменённых файлов: 498 добавлений и 453 удалений

Просмотреть файл

@ -2,11 +2,16 @@
This repository provides recommended RuboCop configuration and additional Cops for use on GitHub open source and internal Ruby projects.
## Installation
## 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"
```
@ -19,6 +24,25 @@ inherit_gem:
- config/rails.yml
```
### Edge usage
**Gemfile**
``` ruby
gem "rubocop-github"
gem "rubocop-performance", require: false
gem "rubocop-rails", require: false
```
**.rubocop.yml**
``` yaml
inherit_gem:
rubocop-github:
- config/default_edge.yml
- config/rails_edge.yml
```
## Testing
`bundle install`

325
config/_default_shared.yml Normal file
Просмотреть файл

@ -0,0 +1,325 @@
require: rubocop/cop/github
# These cops are compatible across supported versions of rubocop
Bundler/DuplicatedGem:
Enabled: true
Bundler/OrderedGems:
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/InitialIndentation:
Enabled: true
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/Tab:
Enabled: true
Layout/TrailingBlankLines:
Enabled: true
Layout/TrailingWhitespace:
Enabled: true
Lint/CircularArgumentReference:
Enabled: true
Lint/Debugger:
Enabled: true
Lint/DeprecatedClassMethods:
Enabled: true
Lint/DuplicateMethods:
Enabled: true
Lint/DuplicatedKey:
Enabled: true
Lint/EachWithObjectArgument:
Enabled: true
Lint/ElseLayout:
Enabled: true
Lint/EmptyEnsure:
Enabled: true
Lint/EmptyInterpolation:
Enabled: true
Lint/EndInMethod:
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/StringConversionInInterpolation:
Enabled: true
Lint/UnderscorePrefixedVariableName:
Enabled: true
Lint/UnneededCopDisableDirective:
Enabled: true
Lint/UnneededSplatExpansion:
Enabled: true
Lint/UnreachableCode:
Enabled: true
Lint/UselessComparison:
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/LineLength:
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

120
config/_rails_shared.yml Normal file
Просмотреть файл

@ -0,0 +1,120 @@
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/TrailingBlankLines:
Exclude:
- 'app/views/**/*.erb'
Layout/TrailingWhitespace:
Exclude:
- 'app/views/**/*.erb'
Layout/InitialIndentation:
Exclude:
- 'app/views/**/*.erb'
Lint/UselessAccessModifier:
ContextCreatingMethods:
- concerning

Просмотреть файл

@ -1,326 +1,2 @@
require: rubocop/cop/github
AllCops:
DisabledByDefault: true
Bundler/DuplicatedGem:
Enabled: true
Bundler/OrderedGems:
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/InitialIndentation:
Enabled: true
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/Tab:
Enabled: true
Layout/TrailingBlankLines:
Enabled: true
Layout/TrailingWhitespace:
Enabled: true
Lint/CircularArgumentReference:
Enabled: true
Lint/Debugger:
Enabled: true
Lint/DeprecatedClassMethods:
Enabled: true
Lint/DuplicateMethods:
Enabled: true
Lint/DuplicatedKey:
Enabled: true
Lint/EachWithObjectArgument:
Enabled: true
Lint/ElseLayout:
Enabled: true
Lint/EmptyEnsure:
Enabled: true
Lint/EmptyInterpolation:
Enabled: true
Lint/EndInMethod:
Enabled: true
Lint/EnsureReturn:
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/StringConversionInInterpolation:
Enabled: true
Lint/UnderscorePrefixedVariableName:
Enabled: true
Lint/UnneededCopDisableDirective:
Enabled: true
Lint/UnneededSplatExpansion:
Enabled: true
Lint/UnreachableCode:
Enabled: true
Lint/UselessComparison:
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/LineLength:
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/RedundantSortBy:
Enabled: true
Performance/ReverseEach:
Enabled: true
Performance/Sample:
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/FlipFlop:
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/StabbyLambdaParentheses:
Enabled: true
Style/Strip:
Enabled: true
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes
# Inherit from default_deprecated until 1.0
inherit_from: default_deprecated.yml

Просмотреть файл

@ -0,0 +1,4 @@
inherit_from: _default_shared.yml
AllCops:
DisabledByDefault: true

4
config/default_edge.yml Normal file
Просмотреть файл

@ -0,0 +1,4 @@
inherit_from: _default_shared.yml
require:
- rubocop-performance

Просмотреть файл

@ -1,126 +1,2 @@
Rails:
Enabled: true
Rails/FindEach:
Enabled: false
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/TrailingBlankLines:
Exclude:
- 'app/views/**/*.erb'
Layout/TrailingWhitespace:
Exclude:
- 'app/views/**/*.erb'
Layout/InitialIndentation:
Exclude:
- 'app/views/**/*.erb'
Lint/UselessAccessModifier:
ContextCreatingMethods:
- concerning
# Inherit from rails_deprecated until 1.0
inherit_from: rails_deprecated.yml

Просмотреть файл

@ -0,0 +1,7 @@
inherit_from: _rails_shared.yml
Rails:
Enabled: true
Rails/FindEach:
Enabled: false

4
config/rails_edge.yml Normal file
Просмотреть файл

@ -0,0 +1,4 @@
inherit_from: _rails_shared.yml
require:
- rubocop-rails

Просмотреть файл

@ -11,6 +11,11 @@ Gem::Specification.new do |s|
s.files = Dir["README.md", "STYLEGUIDE.md", "LICENSE", "config/*.yml", "lib/**/*.rb", "guides/*.md"]
s.add_dependency "rubocop", "~> 0.59"
# TODO: If you use this gem in "edge" mode, it requires both
# rubocop-performance and rubocop-rails but it's not currently possible to
# add these to the gemspec because both of them require a ver recent version
# of rubocop which would break any clients that accidentally `bundle update`.
# This should become much simpler once this gem reaches v1
s.add_development_dependency "actionview", "~> 5.0"
s.add_development_dependency "minitest", "~> 5.10"