- These were `Enabled: false` for the whole group of Rails cops, so my removing the `Enabled: true` cops (what I thought was "redundant" config in the previous commit) meant the specific ones we wanted to use weren't enabled at all. - Instead, let's reverse that by unsetting `Enabled: false` for the whole group, and then disabling the specific cops with offenses that we haven't got around to deciding if we care about yet.
522 lines
13 KiB
YAML
522 lines
13 KiB
YAML
---
|
|
require:
|
|
- ./Homebrew/rubocops.rb
|
|
- rubocop-performance
|
|
- rubocop-rails
|
|
- rubocop-rspec
|
|
- rubocop-sorbet
|
|
|
|
inherit_mode:
|
|
merge:
|
|
- Include
|
|
- Exclude
|
|
|
|
AllCops:
|
|
TargetRubyVersion: 2.6
|
|
ActiveSupportExtensionsEnabled: true
|
|
EnabledByDefault: true
|
|
NewCops: enable
|
|
Include:
|
|
- "**/*.rbi"
|
|
Exclude:
|
|
- "Homebrew/sorbet/rbi/gems/**/*.rbi"
|
|
- "Homebrew/sorbet/rbi/hidden-definitions/*.rbi"
|
|
- "Homebrew/sorbet/rbi/todo.rbi"
|
|
- "Homebrew/bin/*"
|
|
- "Homebrew/vendor/**/*"
|
|
- "Taps/*/*/vendor/**/*"
|
|
|
|
# TODO: This group of cops comes from `EnabledByDefault: true`. We should maybe enable the ones with < 100 offenses.
|
|
Bundler/GemComment:
|
|
Enabled: false
|
|
Bundler/GemVersion:
|
|
Enabled: false
|
|
|
|
Cask/Desc:
|
|
Description: "Ensure that the desc stanza conforms to various content and style checks."
|
|
|
|
Cask/HomepageUrlTrailingSlash:
|
|
Description: "Ensure that the homepage url has a slash after the domain name."
|
|
|
|
Cask/NoDslVersion:
|
|
Description: "Do not use the deprecated DSL version syntax in your cask header."
|
|
|
|
Cask/StanzaGrouping:
|
|
Description: "Ensure that cask stanzas are grouped correctly. More info at https://docs.brew.sh/Cask-Cookbook#stanza-order"
|
|
|
|
Cask/StanzaOrder:
|
|
Description: "Ensure that cask stanzas are sorted correctly. More info at https://docs.brew.sh/Cask-Cookbook#stanza-order"
|
|
|
|
# only used internally
|
|
Homebrew/MoveToExtendOS:
|
|
Enabled: false
|
|
|
|
# `system` is a special case and aligns on second argument, so allow this for formulae.
|
|
Layout/ArgumentAlignment:
|
|
Exclude:
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/Formula/**/*.rb"
|
|
- "**/Formula/**/*.rb"
|
|
|
|
# this is a bit less "floaty"
|
|
Layout/CaseIndentation:
|
|
EnforcedStyle: end
|
|
|
|
# TODO: This group of cops comes from `EnabledByDefault: true`. We should maybe enable the ones with < 100 offenses.
|
|
Layout/ClassStructure:
|
|
Enabled: false
|
|
Layout/EmptyLineAfterMultilineCondition:
|
|
Enabled: false
|
|
Layout/FirstArrayElementLineBreak:
|
|
Enabled: false
|
|
Layout/FirstHashElementLineBreak:
|
|
Enabled: false
|
|
Layout/FirstMethodArgumentLineBreak:
|
|
Enabled: false
|
|
Layout/FirstMethodParameterLineBreak:
|
|
Enabled: false
|
|
Layout/MultilineArrayLineBreaks:
|
|
Enabled: false
|
|
Layout/MultilineAssignmentLayout:
|
|
Enabled: false
|
|
Layout/MultilineHashKeyLineBreaks:
|
|
Enabled: false
|
|
Layout/MultilineMethodArgumentLineBreaks:
|
|
Enabled: false
|
|
Layout/MultilineMethodParameterLineBreaks:
|
|
Enabled: false
|
|
Layout/RedundantLineBreak:
|
|
Enabled: false
|
|
Layout/SingleLineBlockChain:
|
|
Enabled: false
|
|
|
|
# significantly less indentation involved; more consistent
|
|
Layout/FirstArrayElementIndentation:
|
|
EnforcedStyle: consistent
|
|
Layout/FirstHashElementIndentation:
|
|
EnforcedStyle: consistent
|
|
|
|
# this is a bit less "floaty"
|
|
Layout/EndAlignment:
|
|
EnforcedStyleAlignWith: start_of_line
|
|
|
|
# make our hashes consistent
|
|
Layout/HashAlignment:
|
|
EnforcedHashRocketStyle: table
|
|
EnforcedColonStyle: table
|
|
|
|
# Need to allow #: for external commands.
|
|
Layout/LeadingCommentSpace:
|
|
Exclude:
|
|
- "Taps/*/*/cmd/*.rb"
|
|
|
|
# GitHub diff UI wraps beyond 118 characters
|
|
Layout/LineLength:
|
|
Max: 118
|
|
# ignore manpage comments and long single-line strings
|
|
AllowedPatterns:
|
|
[
|
|
"#: ",
|
|
' url "',
|
|
' mirror "',
|
|
" plist_options ",
|
|
' appcast "',
|
|
' executable: "',
|
|
' font "',
|
|
' homepage "',
|
|
' name "',
|
|
' pkg "',
|
|
' pkgutil: "',
|
|
" sha256 cellar: ",
|
|
" sha256 ",
|
|
"#{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",
|
|
]
|
|
|
|
# conflicts with DSL-style path concatenation with `/`
|
|
Layout/SpaceAroundOperators:
|
|
Enabled: false
|
|
|
|
# makes DSL usage ugly.
|
|
Layout/SpaceBeforeBrackets:
|
|
Exclude:
|
|
- "**/*_spec.rb"
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/{Formula,Casks}/**/*.rb"
|
|
- "**/{Formula,Casks}/**/*.rb"
|
|
|
|
# favour parens-less DSL-style arguments
|
|
Lint/AmbiguousBlockAssociation:
|
|
Enabled: false
|
|
|
|
# TODO: This group of cops comes from `EnabledByDefault: true`. We should maybe enable the ones with < 100 offenses.
|
|
Lint/ConstantResolution:
|
|
Enabled: false
|
|
Lint/NumberConversion:
|
|
Enabled: false
|
|
|
|
Lint/DuplicateBranch:
|
|
Exclude:
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/{Formula,Casks}/**/*.rb"
|
|
- "**/{Formula,Casks}/**/*.rb"
|
|
|
|
# so many of these in formulae and can't be autocorrected
|
|
Lint/ParenthesesAsGroupedExpression:
|
|
Exclude:
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/Formula/**/*.rb"
|
|
- "**/Formula/**/*.rb"
|
|
|
|
# unused keyword arguments improve APIs
|
|
Lint/UnusedMethodArgument:
|
|
AllowUnusedKeywordArguments: true
|
|
|
|
# These metrics didn't end up helping.
|
|
Metrics:
|
|
Enabled: false
|
|
|
|
# Allow dashes in filenames.
|
|
Naming/FileName:
|
|
Regex: !ruby/regexp /^[\w\@\-\+\.]+(\.rb)?$/
|
|
|
|
# Implicitly allow EOS as we use it everywhere.
|
|
Naming/HeredocDelimiterNaming:
|
|
ForbiddenDelimiters:
|
|
- END, EOD, EOF
|
|
|
|
Naming/InclusiveLanguage:
|
|
CheckStrings: true
|
|
FlaggedTerms:
|
|
# TODO: If possible, make this stricter.
|
|
slave:
|
|
AllowedRegex:
|
|
- "gitslave" # Used in formula `gitslave`
|
|
- "log_slave" # Used in formula `ssdb`
|
|
- "ssdb_slave" # Used in formula `ssdb`
|
|
- "var_slave" # Used in formula `ssdb`
|
|
- "patches/13_fix_scope_for_show_slave_status_data.patch" # Used in formula `mytop`
|
|
|
|
Naming/MethodName:
|
|
AllowedPatterns:
|
|
- '\A(fetch_)?HEAD\?\Z'
|
|
|
|
Naming/MethodParameterName:
|
|
inherit_mode:
|
|
merge:
|
|
- AllowedNames
|
|
|
|
# Both styles are used depending on context,
|
|
# e.g. `sha256` and `something_countable_1`.
|
|
Naming/VariableNumber:
|
|
Enabled: false
|
|
|
|
# Makes code less readable for minor performance increases.
|
|
Performance/Caller:
|
|
Enabled: false
|
|
|
|
# Makes code less readable for minor performance increases.
|
|
Performance/MethodObjectAsBlock:
|
|
Enabled: false
|
|
|
|
# TODO: This group of cops comes from `EnabledByDefault: true`. We should maybe enable the ones with < 100 offenses.
|
|
Performance/ChainArrayAllocation:
|
|
Enabled: false
|
|
Performance/IoReadlines:
|
|
Enabled: false
|
|
Performance/OpenStruct:
|
|
Enabled: false
|
|
|
|
Rails:
|
|
# Do not use ActiveSupport in RuboCops.
|
|
Exclude:
|
|
- "Homebrew/rubocops/**/*"
|
|
|
|
Rails/Delegate:
|
|
Enabled: false # TODO
|
|
|
|
# TODO: This group of cops comes from `EnabledByDefault: true`. We should maybe enable the ones with < 100 offenses.
|
|
Rails/ArelStar:
|
|
Enabled: false
|
|
Rails/Date:
|
|
Enabled: false
|
|
Rails/RakeEnvironment:
|
|
Enabled: false
|
|
Rails/Pluck:
|
|
Enabled: false
|
|
Rails/SaveBang:
|
|
Enabled: false
|
|
Rails/SkipsModelValidations:
|
|
Enabled: false
|
|
Rails/TimeZone:
|
|
Enabled: false
|
|
|
|
# Intentionally disabled as it doesn't fit with our code style.
|
|
RSpec/AnyInstance:
|
|
Enabled: false
|
|
RSpec/DescribeClass:
|
|
Enabled: false
|
|
RSpec/FilePath:
|
|
Enabled: false
|
|
RSpec/StubbedMock:
|
|
Enabled: false
|
|
RSpec/SubjectStub:
|
|
Enabled: false
|
|
|
|
# TODO: These cops come from `EnabledByDefault: true`. We should maybe enable the ones with < 100 offenses.
|
|
RSpec/AlignLeftLetBrace:
|
|
Enabled: false
|
|
RSpec/AlignRightLetBrace:
|
|
Enabled: false
|
|
RSpec/MessageExpectation:
|
|
Enabled: false
|
|
RSpec/Pending:
|
|
Enabled: false
|
|
|
|
# We use `allow(:foo).to receive(:bar)` everywhere.
|
|
RSpec/MessageSpies:
|
|
EnforcedStyle: receive
|
|
|
|
# These were ever-growing numbers, not useful.
|
|
RSpec/ExampleLength:
|
|
Enabled: false
|
|
RSpec/MultipleExpectations:
|
|
Enabled: false
|
|
RSpec/NestedGroups:
|
|
Enabled: false
|
|
RSpec/MultipleMemoizedHelpers:
|
|
Enabled: false
|
|
|
|
# Annoying to have these autoremoved.
|
|
RSpec/Focus:
|
|
AutoCorrect: false
|
|
|
|
# Try getting rid of these.
|
|
Sorbet/ConstantsFromStrings:
|
|
Enabled: false
|
|
|
|
# This is already the default
|
|
Sorbet/FalseSigil:
|
|
Enabled: false
|
|
|
|
# TODO: These cops come from `EnabledByDefault: true`. We should maybe enable the ones with < 100 offenses.
|
|
Sorbet/EnforceSignatures:
|
|
Enabled: false
|
|
Sorbet/ForbidTUnsafe:
|
|
Enabled: false
|
|
Sorbet/ForbidTUntyped:
|
|
Enabled: false
|
|
Sorbet/HasSigil:
|
|
Enabled: false
|
|
Sorbet/IgnoreSigil:
|
|
Enabled: false
|
|
Sorbet/StrongSigil:
|
|
Enabled: false
|
|
|
|
Sorbet/StrictSigil:
|
|
inherit_mode:
|
|
override:
|
|
- Include
|
|
Include:
|
|
- "**/*.rbi"
|
|
|
|
Sorbet/TrueSigil:
|
|
Exclude:
|
|
- "Taps/**/*"
|
|
- "/**/{Formula,Casks}/**/*.rb"
|
|
- "**/{Formula,Casks}/**/*.rb"
|
|
- "Homebrew/test/**/*.rb"
|
|
|
|
# Require &&/|| instead of and/or
|
|
Style/AndOr:
|
|
EnforcedStyle: always
|
|
|
|
# This makes these a little more obvious.
|
|
Style/BarePercentLiterals:
|
|
EnforcedStyle: percent_q
|
|
|
|
Style/BlockDelimiters:
|
|
BracesRequiredMethods:
|
|
- "sig"
|
|
|
|
# TODO: This group of cops comes from `EnabledByDefault: true`. We should maybe enable the ones with < 100 offenses.
|
|
Style/ArrayCoercion:
|
|
Enabled: false
|
|
Style/AsciiComments:
|
|
Enabled: false
|
|
Style/ClassMethodsDefinitions:
|
|
Enabled: false
|
|
Style/ConstantVisibility:
|
|
Enabled: false
|
|
Style/Copyright:
|
|
Enabled: false
|
|
Style/DateTime:
|
|
Enabled: false
|
|
Style/DocumentationMethod:
|
|
Enabled: false
|
|
Style/ImplicitRuntimeError:
|
|
Enabled: false
|
|
Style/InlineComment:
|
|
Enabled: false
|
|
Style/IpAddresses:
|
|
Enabled: false
|
|
Style/MethodCallWithArgsParentheses:
|
|
Enabled: false
|
|
Style/MethodCalledOnDoEndBlock:
|
|
Enabled: false
|
|
Style/MissingElse:
|
|
Enabled: false
|
|
Style/MultilineMethodSignature:
|
|
Enabled: false
|
|
Style/OptionHash:
|
|
Enabled: false
|
|
Style/RequireOrder:
|
|
Enabled: false
|
|
Style/Send:
|
|
Enabled: false
|
|
Style/SingleLineBlockParams:
|
|
Enabled: false
|
|
Style/StaticClass:
|
|
Enabled: false
|
|
Style/StringHashKeys:
|
|
Enabled: false
|
|
Style/TopLevelMethodDefinition:
|
|
Enabled: false
|
|
Style/TrailingCommaInBlockArgs:
|
|
Enabled: false
|
|
Style/YodaExpression:
|
|
Enabled: false
|
|
|
|
# Don't allow cops to be disabled in casks and formulae.
|
|
Style/DisableCopsWithinSourceCodeDirective:
|
|
Include:
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/{Formula,Casks}/**/*.rb"
|
|
- "**/{Formula,Casks}/**/*.rb"
|
|
|
|
# The files actually scanned in this cop are in `Library/Homebrew/.rubocop.yml`.
|
|
Style/Documentation:
|
|
Exclude:
|
|
- "Taps/**/*"
|
|
- "/**/{Formula,Casks}/**/*.rb"
|
|
- "**/{Formula,Casks}/**/*.rb"
|
|
- "**/*.rbi"
|
|
|
|
# This is quite a large change, so don't enforce this yet for formulae.
|
|
# We should consider doing so in the future, but be aware of the impact on third-party taps.
|
|
Style/FetchEnvVar:
|
|
Exclude:
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/Formula/**/*.rb"
|
|
- "**/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"
|
|
|
|
# potential for errors in formulae too high with this
|
|
Style/GuardClause:
|
|
Exclude:
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/{Formula,Casks}/**/*.rb"
|
|
- "**/{Formula,Casks}/**/*.rb"
|
|
|
|
# Allow for license expressions
|
|
Style/HashAsLastArrayItem:
|
|
Exclude:
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/Formula/**/*.rb"
|
|
- "**/Formula/**/*.rb"
|
|
|
|
Style/InvertibleUnlessCondition:
|
|
InverseMethods:
|
|
# Favor `if a != b` over `unless a == b`
|
|
:==: :!=
|
|
# Unset this (prefer `unless a.zero?` over `if a.nonzero?`)
|
|
:zero?:
|
|
|
|
# would rather freeze too much than too little
|
|
Style/MutableConstant:
|
|
EnforcedStyle: strict
|
|
|
|
# Zero-prefixed octal literals are widely used and understood.
|
|
Style/NumericLiteralPrefix:
|
|
EnforcedOctalStyle: zero_only
|
|
|
|
# Only use this for numbers >= `1_000_000`.
|
|
Style/NumericLiterals:
|
|
MinDigits: 7
|
|
Strict: true
|
|
Exclude:
|
|
- "**/Brewfile"
|
|
|
|
# TODO: These are pre-existing violations and should be corrected
|
|
# to define methods so that call sites can be type-checked.
|
|
Style/OpenStructUse:
|
|
Exclude:
|
|
- "Homebrew/cli/args.rb"
|
|
- "Taps/**/*.rb"
|
|
|
|
# Rescuing `StandardError` is an understood default.
|
|
Style/RescueStandardError:
|
|
EnforcedStyle: implicit
|
|
|
|
# We have no use for using `warn` because we
|
|
# are calling Ruby with warnings disabled.
|
|
Style/StderrPuts:
|
|
Enabled: false
|
|
|
|
# so many of these in formulae and can't be autocorrected
|
|
Style/StringConcatenation:
|
|
Exclude:
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/{Formula,Casks}/**/*.rb"
|
|
- "**/{Formula,Casks}/**/*.rb"
|
|
|
|
# ruby style guide favorite
|
|
Style/StringLiterals:
|
|
EnforcedStyle: double_quotes
|
|
|
|
# consistency with above
|
|
Style/StringLiteralsInInterpolation:
|
|
EnforcedStyle: double_quotes
|
|
|
|
# An array of symbols is more readable than a symbol array
|
|
# and also allows for easier grepping.
|
|
Style/SymbolArray:
|
|
EnforcedStyle: brackets
|
|
|
|
# make things a bit easier to read
|
|
Style/TernaryParentheses:
|
|
EnforcedStyle: require_parentheses_when_complex
|
|
|
|
# Trailing commas make diffs nicer.
|
|
Style/TrailingCommaInArguments:
|
|
EnforcedStyleForMultiline: comma
|
|
Style/TrailingCommaInArrayLiteral:
|
|
EnforcedStyleForMultiline: comma
|
|
Style/TrailingCommaInHashLiteral:
|
|
EnforcedStyleForMultiline: comma
|
|
|
|
# `unless ... ||` and `unless ... &&` are hard to mentally parse
|
|
Style/UnlessLogicalOperators:
|
|
EnforcedStyle: forbid_logical_operators
|
|
|
|
# a bit confusing to non-Rubyists but useful for longer arrays
|
|
Style/WordArray:
|
|
MinSize: 4
|