Add and enable rubocop-rails.
This will help us catch and cleanup usage of e.g. `.blank?` and other helpers we use from ActiveSupport.
This commit is contained in:
parent
cf70a511bb
commit
8528eff604
1
.gitignore
vendored
1
.gitignore
vendored
@ -35,6 +35,7 @@
|
||||
# Unignore vendored gems
|
||||
!**/vendor/bundle/ruby/*/gems/*/lib
|
||||
!**/vendor/bundle/ruby/*/gems/rubocop-performance-*/config
|
||||
!**/vendor/bundle/ruby/*/gems/rubocop-rails-*/config
|
||||
!**/vendor/bundle/ruby/*/gems/rubocop-rspec-*/config
|
||||
!**/vendor/bundle/ruby/*/gems/rubocop-sorbet-*/config
|
||||
|
||||
|
||||
@ -13,33 +13,34 @@ AllCops:
|
||||
# enable all pending rubocops
|
||||
NewCops: enable
|
||||
Include:
|
||||
- '**/*.rbi'
|
||||
- "**/*.rbi"
|
||||
Exclude:
|
||||
- 'Homebrew/sorbet/rbi/gems/**/*.rbi'
|
||||
- 'Homebrew/sorbet/rbi/hidden-definitions/**/*.rbi'
|
||||
- 'Homebrew/sorbet/rbi/todo.rbi'
|
||||
- 'Homebrew/sorbet/rbi/upstream.rbi'
|
||||
- 'Homebrew/bin/*'
|
||||
- 'Homebrew/vendor/**/*'
|
||||
- "Homebrew/sorbet/rbi/gems/**/*.rbi"
|
||||
- "Homebrew/sorbet/rbi/hidden-definitions/**/*.rbi"
|
||||
- "Homebrew/sorbet/rbi/todo.rbi"
|
||||
- "Homebrew/sorbet/rbi/upstream.rbi"
|
||||
- "Homebrew/bin/*"
|
||||
- "Homebrew/vendor/**/*"
|
||||
- "Taps/*/*/vendor/**/*"
|
||||
|
||||
Cask/Desc:
|
||||
Description: 'Ensure that the desc stanza conforms to various content and style checks.'
|
||||
Description: "Ensure that the desc stanza conforms to various content and style checks."
|
||||
Enabled: true
|
||||
|
||||
Cask/HomepageUrlTrailingSlash:
|
||||
Description: 'Ensure that the homepage url has a slash after the domain name.'
|
||||
Description: "Ensure that the homepage url has a slash after the domain name."
|
||||
Enabled: true
|
||||
|
||||
Cask/NoDslVersion:
|
||||
Description: 'Do not use the deprecated DSL version syntax in your cask header.'
|
||||
Description: "Do not use the deprecated DSL version syntax in your cask header."
|
||||
Enabled: true
|
||||
|
||||
Cask/StanzaGrouping:
|
||||
Description: 'Ensure that cask stanzas are grouped correctly. More info at https://github.com/Homebrew/homebrew-cask/blob/HEAD/doc/cask_language_reference/readme.md#stanza-order'
|
||||
Description: "Ensure that cask stanzas are grouped correctly. More info at https://github.com/Homebrew/homebrew-cask/blob/HEAD/doc/cask_language_reference/readme.md#stanza-order"
|
||||
Enabled: true
|
||||
|
||||
Cask/StanzaOrder:
|
||||
Description: 'Ensure that cask stanzas are sorted correctly. More info at https://github.com/Homebrew/homebrew-cask/blob/HEAD/doc/cask_language_reference/readme.md#stanza-order'
|
||||
Description: "Ensure that cask stanzas are sorted correctly. More info at https://github.com/Homebrew/homebrew-cask/blob/HEAD/doc/cask_language_reference/readme.md#stanza-order"
|
||||
Enabled: true
|
||||
|
||||
# enable all formulae audits
|
||||
@ -105,9 +106,9 @@ Style/HashTransformValues:
|
||||
# Allow for license expressions
|
||||
Style/HashAsLastArrayItem:
|
||||
Exclude:
|
||||
- 'Taps/*/*/*.rb'
|
||||
- '/**/Formula/*.rb'
|
||||
- '**/Formula/*.rb'
|
||||
- "Taps/*/*/*.rb"
|
||||
- "/**/Formula/*.rb"
|
||||
- "**/Formula/*.rb"
|
||||
|
||||
# Enabled now LineLength is lowish.
|
||||
Style/IfUnlessModifier:
|
||||
@ -118,7 +119,7 @@ Style/NumericLiterals:
|
||||
MinDigits: 7
|
||||
Strict: true
|
||||
Exclude:
|
||||
- '**/Brewfile'
|
||||
- "**/Brewfile"
|
||||
|
||||
# Zero-prefixed octal literals are widely used and understood.
|
||||
Style/NumericLiteralPrefix:
|
||||
@ -166,13 +167,30 @@ Performance/Caller:
|
||||
Performance/MethodObjectAsBlock:
|
||||
Enabled: false
|
||||
|
||||
# Cannot use ActiveSupport in RuboCops.
|
||||
Rails:
|
||||
Exclude:
|
||||
- "Homebrew/rubocops/**/*"
|
||||
|
||||
# Skip these as they only apply to actual Rails and not our ActiveSupport usage.
|
||||
Rails/Date:
|
||||
Enabled: false
|
||||
Rails/Delegate:
|
||||
Enabled: false
|
||||
Rails/SkipsModelValidations:
|
||||
Enabled: false
|
||||
Rails/Pluck:
|
||||
Enabled: false
|
||||
Rails/TimeZone:
|
||||
Enabled: false
|
||||
|
||||
# Don't allow cops to be disabled in casks and formulae.
|
||||
Style/DisableCopsWithinSourceCodeDirective:
|
||||
Enabled: true
|
||||
Include:
|
||||
- 'Taps/*/*/*.rb'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- "Taps/*/*/*.rb"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
|
||||
# make our hashes consistent
|
||||
Layout/HashAlignment:
|
||||
@ -182,9 +200,9 @@ Layout/HashAlignment:
|
||||
# `system` is a special case and aligns on second argument, so allow this for formulae.
|
||||
Layout/ArgumentAlignment:
|
||||
Exclude:
|
||||
- 'Taps/*/*/*.rb'
|
||||
- '/**/Formula/*.rb'
|
||||
- '**/Formula/*.rb'
|
||||
- "Taps/*/*/*.rb"
|
||||
- "/**/Formula/*.rb"
|
||||
- "**/Formula/*.rb"
|
||||
|
||||
# this is a bit less "floaty"
|
||||
Layout/CaseIndentation:
|
||||
@ -208,120 +226,137 @@ Lint/AmbiguousBlockAssociation:
|
||||
|
||||
Lint/DuplicateBranch:
|
||||
Exclude:
|
||||
- 'Taps/*/*/*.rb'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- "Taps/*/*/*.rb"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
|
||||
# needed for lazy_object magic
|
||||
Naming/MemoizedInstanceVariableName:
|
||||
Exclude:
|
||||
- 'Homebrew/lazy_object.rb'
|
||||
- "Homebrew/lazy_object.rb"
|
||||
|
||||
# so many of these in formulae and can't be autocorrected
|
||||
# TODO: fix these as `ruby -w` complains about them.
|
||||
Lint/AmbiguousRegexpLiteral:
|
||||
Exclude:
|
||||
- 'Taps/*/*/*.rb'
|
||||
- '/**/Formula/*.rb'
|
||||
- '**/Formula/*.rb'
|
||||
- "Taps/*/*/*.rb"
|
||||
- "/**/Formula/*.rb"
|
||||
- "**/Formula/*.rb"
|
||||
|
||||
# useful for metaprogramming in RSpec
|
||||
Lint/ConstantDefinitionInBlock:
|
||||
Exclude:
|
||||
- '**/*_spec.rb'
|
||||
- "**/*_spec.rb"
|
||||
|
||||
# so many of these in formulae and can't be autocorrected
|
||||
Lint/ParenthesesAsGroupedExpression:
|
||||
Exclude:
|
||||
- 'Taps/*/*/*.rb'
|
||||
- '/**/Formula/*.rb'
|
||||
- '**/Formula/*.rb'
|
||||
- "Taps/*/*/*.rb"
|
||||
- "/**/Formula/*.rb"
|
||||
- "**/Formula/*.rb"
|
||||
|
||||
# Most metrics don't make sense to apply for casks/formulae/taps.
|
||||
Metrics/AbcSize:
|
||||
Exclude:
|
||||
- 'Taps/**/*'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- "Taps/**/*"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
Metrics/BlockLength:
|
||||
Exclude:
|
||||
- 'Taps/**/*'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- "Taps/**/*"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
Metrics/ClassLength:
|
||||
Exclude:
|
||||
- 'Taps/**/*'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- "Taps/**/*"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
Metrics/CyclomaticComplexity:
|
||||
Exclude:
|
||||
- 'Taps/**/*'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- "Taps/**/*"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
Metrics/MethodLength:
|
||||
Exclude:
|
||||
- 'Taps/**/*'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- "Taps/**/*"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
Metrics/ModuleLength:
|
||||
Exclude:
|
||||
- 'Taps/**/*'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- "Taps/**/*"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
Metrics/PerceivedComplexity:
|
||||
Exclude:
|
||||
- 'Taps/**/*'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- "Taps/**/*"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
|
||||
# allow those that are standard
|
||||
# TODO: try to remove some of these
|
||||
Naming/MethodParameterName:
|
||||
AllowedNames:
|
||||
- '_'
|
||||
- 'a'
|
||||
- 'b'
|
||||
- 'cc'
|
||||
- 'c1'
|
||||
- 'c2'
|
||||
- 'd'
|
||||
- 'e'
|
||||
- 'f'
|
||||
- 'ff'
|
||||
- 'fn'
|
||||
- 'id'
|
||||
- 'io'
|
||||
- 'o'
|
||||
- 'p'
|
||||
- 'pr'
|
||||
- 'r'
|
||||
- 'rb'
|
||||
- 's'
|
||||
- 'to'
|
||||
- 'v'
|
||||
- "_"
|
||||
- "a"
|
||||
- "b"
|
||||
- "cc"
|
||||
- "c1"
|
||||
- "c2"
|
||||
- "d"
|
||||
- "e"
|
||||
- "f"
|
||||
- "ff"
|
||||
- "fn"
|
||||
- "id"
|
||||
- "io"
|
||||
- "o"
|
||||
- "p"
|
||||
- "pr"
|
||||
- "r"
|
||||
- "rb"
|
||||
- "s"
|
||||
- "to"
|
||||
- "v"
|
||||
|
||||
# GitHub diff UI wraps beyond 118 characters
|
||||
Layout/LineLength:
|
||||
Max: 118
|
||||
# ignore manpage comments and long single-line strings
|
||||
IgnoredPatterns: ['#: ', ' url "', ' mirror "', ' plist_options ',
|
||||
' appcast "', ' executable: "', ' font "', ' homepage "', ' name "',
|
||||
' pkg "', ' pkgutil: "', '#{language}', '#{version.',
|
||||
' "/Library/Application Support/', '"/Library/Caches/', '"/Library/PreferencePanes/',
|
||||
' "~/Library/Application Support/', '"~/Library/Caches/', '"~/Application Support',
|
||||
' was verified as official when first introduced to the cask']
|
||||
IgnoredPatterns:
|
||||
[
|
||||
"#: ",
|
||||
' url "',
|
||||
' mirror "',
|
||||
" plist_options ",
|
||||
' appcast "',
|
||||
' executable: "',
|
||||
' font "',
|
||||
' homepage "',
|
||||
' name "',
|
||||
' pkg "',
|
||||
' pkgutil: "',
|
||||
"#{language}",
|
||||
"#{version.",
|
||||
' "/Library/Application Support/',
|
||||
'"/Library/Caches/',
|
||||
'"/Library/PreferencePanes/',
|
||||
' "~/Library/Application Support/',
|
||||
'"~/Library/Caches/',
|
||||
'"~/Application Support',
|
||||
" was verified as official when first introduced to the cask",
|
||||
]
|
||||
|
||||
Sorbet/FalseSigil:
|
||||
Exclude:
|
||||
- 'Taps/**/*'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- 'Homebrew/test/**/Casks/**/*.rb'
|
||||
- "Taps/**/*"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
- "Homebrew/test/**/Casks/**/*.rb"
|
||||
|
||||
Sorbet/StrictSigil:
|
||||
Enabled: true
|
||||
Include:
|
||||
- '**/*.rbi'
|
||||
- "**/*.rbi"
|
||||
|
||||
# Try getting rid of these.
|
||||
Sorbet/ConstantsFromStrings:
|
||||
@ -339,48 +374,48 @@ Style/AccessorGrouping:
|
||||
# make rspec formatting more flexible
|
||||
Style/BlockDelimiters:
|
||||
Exclude:
|
||||
- 'Homebrew/**/*_spec.rb'
|
||||
- 'Homebrew/**/shared_examples/**/*.rb'
|
||||
- "Homebrew/**/*_spec.rb"
|
||||
- "Homebrew/**/shared_examples/**/*.rb"
|
||||
|
||||
# TODO: remove this when possible.
|
||||
Style/ClassVars:
|
||||
Exclude:
|
||||
- '**/developer/bin/*'
|
||||
- "**/developer/bin/*"
|
||||
|
||||
# Don't enforce documentation in casks or formulae.
|
||||
Style/Documentation:
|
||||
Exclude:
|
||||
- 'Taps/**/*'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- '**/*.rbi'
|
||||
- "Taps/**/*"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
- "**/*.rbi"
|
||||
|
||||
Style/DocumentationMethod:
|
||||
Include:
|
||||
- 'Homebrew/formula.rb'
|
||||
- "Homebrew/formula.rb"
|
||||
|
||||
# Not used for casks and formulae.
|
||||
Style/FrozenStringLiteralComment:
|
||||
EnforcedStyle: always
|
||||
Exclude:
|
||||
- 'Taps/*/*/*.rb'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- 'Homebrew/test/**/Casks/**/*.rb'
|
||||
- '**/*.rbi'
|
||||
- '**/Brewfile'
|
||||
- "Taps/*/*/*.rb"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
- "Homebrew/test/**/Casks/**/*.rb"
|
||||
- "**/*.rbi"
|
||||
- "**/Brewfile"
|
||||
|
||||
# TODO: remove this when possible.
|
||||
Style/GlobalVars:
|
||||
Exclude:
|
||||
- '**/developer/bin/*'
|
||||
- "**/developer/bin/*"
|
||||
|
||||
# potential for errors in formulae too high with this
|
||||
Style/GuardClause:
|
||||
Exclude:
|
||||
- 'Taps/*/*/*.rb'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- "Taps/*/*/*.rb"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
|
||||
# avoid hash rockets where possible
|
||||
Style/HashSyntax:
|
||||
@ -389,9 +424,9 @@ Style/HashSyntax:
|
||||
# so many of these in formulae and can't be autocorrected
|
||||
Style/StringConcatenation:
|
||||
Exclude:
|
||||
- 'Taps/*/*/*.rb'
|
||||
- '/**/{Formula,Casks}/*.rb'
|
||||
- '**/{Formula,Casks}/*.rb'
|
||||
- "Taps/*/*/*.rb"
|
||||
- "/**/{Formula,Casks}/*.rb"
|
||||
- "**/{Formula,Casks}/*.rb"
|
||||
|
||||
# ruby style guide favorite
|
||||
Style/StringLiterals:
|
||||
|
||||
@ -25,6 +25,7 @@ gem "mechanize"
|
||||
gem "patchelf"
|
||||
gem "plist"
|
||||
gem "rubocop-performance"
|
||||
gem "rubocop-rails"
|
||||
gem "rubocop-rspec"
|
||||
gem "rubocop-sorbet"
|
||||
gem "ruby-macho"
|
||||
|
||||
@ -70,6 +70,7 @@ GEM
|
||||
pry (0.13.1)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
rack (2.2.3)
|
||||
rainbow (3.0.0)
|
||||
rdiscount (2.2.0.2)
|
||||
regexp_parser (2.0.0)
|
||||
@ -115,6 +116,10 @@ GEM
|
||||
rubocop-performance (1.9.1)
|
||||
rubocop (>= 0.90.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
rubocop-rails (2.8.1)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 0.87.0)
|
||||
rubocop-rspec (2.0.0)
|
||||
rubocop (~> 1.0)
|
||||
rubocop-ast (>= 1.1.0)
|
||||
@ -176,6 +181,7 @@ DEPENDENCIES
|
||||
rspec-wait
|
||||
rubocop
|
||||
rubocop-performance
|
||||
rubocop-rails
|
||||
rubocop-rspec
|
||||
rubocop-sorbet
|
||||
ruby-macho
|
||||
|
||||
@ -6,6 +6,7 @@ require_relative "load_path"
|
||||
require "utils/sorbet"
|
||||
|
||||
require "rubocop-performance"
|
||||
require "rubocop-rails"
|
||||
require "rubocop-rspec"
|
||||
require "rubocop-sorbet"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user