- As I was looking through the RuboCop configs for
`Naming/MethodParameterName`, since there was a fairly long-standing
TODO here, I found that in the default RuboCop configs the method
names `to` and `io` are
[allowed by default](41a8249b35/config/default.yml (L2794)).
- But we weren't inheriting those allowed names correctly from the
default configuration. This fixes that so that we get future
enhancements automatically for this particular cop allowlist.
544 lines
12 KiB
YAML
544 lines
12 KiB
YAML
# TODO: Try getting more rules in sync.
|
|
|
|
require:
|
|
- ./Homebrew/rubocops.rb
|
|
- rubocop-performance
|
|
- rubocop-rails
|
|
|
|
inherit_mode:
|
|
merge:
|
|
- Include
|
|
- Exclude
|
|
|
|
AllCops:
|
|
TargetRubyVersion: 2.6
|
|
DisplayCopNames: false
|
|
ActiveSupportExtensionsEnabled: true
|
|
# enable all pending rubocops
|
|
NewCops: enable
|
|
Include:
|
|
- "**/*.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/**/*"
|
|
- "Taps/*/*/vendor/**/*"
|
|
|
|
Cask/Desc:
|
|
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."
|
|
Enabled: true
|
|
|
|
Cask/NoDslVersion:
|
|
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://docs.brew.sh/Cask-Cookbook#stanza-order"
|
|
Enabled: true
|
|
|
|
Cask/StanzaOrder:
|
|
Description: "Ensure that cask stanzas are sorted correctly. More info at https://docs.brew.sh/Cask-Cookbook#stanza-order"
|
|
Enabled: true
|
|
|
|
# enable all formulae audits
|
|
FormulaAudit:
|
|
Enabled: true
|
|
|
|
# enable all formulae strict audits
|
|
FormulaAuditStrict:
|
|
Enabled: true
|
|
|
|
# enable all Homebrew custom cops
|
|
Homebrew:
|
|
Enabled: true
|
|
|
|
# makes DSL usage ugly.
|
|
Layout/SpaceBeforeBrackets:
|
|
Exclude:
|
|
- "**/*_spec.rb"
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/{Formula,Casks}/*.rb"
|
|
- "**/{Formula,Casks}/*.rb"
|
|
|
|
# Use `<<~` for heredocs.
|
|
Layout/HeredocIndentation:
|
|
Enabled: true
|
|
|
|
# Keyword arguments don't have the same readability
|
|
# problems as normal parameters.
|
|
Metrics/ParameterLists:
|
|
CountKeywordArgs: 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'
|
|
|
|
# Both styles are used depending on context,
|
|
# e.g. `sha256` and `something_countable_1`.
|
|
Naming/VariableNumber:
|
|
Enabled: false
|
|
|
|
# Require &&/|| instead of and/or
|
|
Style/AndOr:
|
|
Enabled: true
|
|
EnforcedStyle: always
|
|
|
|
# Avoid leaking resources.
|
|
Style/AutoResourceCleanup:
|
|
Enabled: true
|
|
|
|
# This makes these a little more obvious.
|
|
Style/BarePercentLiterals:
|
|
EnforcedStyle: percent_q
|
|
|
|
# Use consistent style for better readability.
|
|
Style/CollectionMethods:
|
|
Enabled: true
|
|
|
|
# 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"
|
|
|
|
# Prefer tokens with type annotations for consistency
|
|
# between formatting numbers and strings.
|
|
Style/FormatStringToken:
|
|
EnforcedStyle: annotated
|
|
|
|
# autocorrectable and more readable
|
|
Style/HashEachMethods:
|
|
Enabled: true
|
|
Style/HashTransformKeys:
|
|
Enabled: true
|
|
Style/HashTransformValues:
|
|
Enabled: true
|
|
|
|
# Allow for license expressions
|
|
Style/HashAsLastArrayItem:
|
|
Exclude:
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/Formula/*.rb"
|
|
- "**/Formula/*.rb"
|
|
|
|
# Enabled now LineLength is lowish.
|
|
Style/IfUnlessModifier:
|
|
Enabled: true
|
|
|
|
# Only use this for numbers >= `1_000_000`.
|
|
Style/NumericLiterals:
|
|
MinDigits: 7
|
|
Strict: true
|
|
Exclude:
|
|
- "**/Brewfile"
|
|
|
|
# Zero-prefixed octal literals are widely used and understood.
|
|
Style/NumericLiteralPrefix:
|
|
EnforcedOctalStyle: zero_only
|
|
|
|
# Rescuing `StandardError` is an understood default.
|
|
Style/RescueStandardError:
|
|
EnforcedStyle: implicit
|
|
|
|
# Returning `nil` is unnecessary.
|
|
Style/ReturnNil:
|
|
Enabled: true
|
|
|
|
# We have no use for using `warn` because we
|
|
# are calling Ruby with warnings disabled.
|
|
Style/StderrPuts:
|
|
Enabled: false
|
|
|
|
# Use consistent method names.
|
|
Style/StringMethods:
|
|
Enabled: true
|
|
|
|
# An array of symbols is more readable than a symbol array
|
|
# and also allows for easier grepping.
|
|
Style/SymbolArray:
|
|
EnforcedStyle: brackets
|
|
|
|
# Trailing commas make diffs nicer.
|
|
Style/TrailingCommaInArguments:
|
|
EnforcedStyleForMultiline: comma
|
|
Style/TrailingCommaInArrayLiteral:
|
|
EnforcedStyleForMultiline: comma
|
|
Style/TrailingCommaInHashLiteral:
|
|
EnforcedStyleForMultiline: comma
|
|
|
|
# Does not hinder readability, so might as well enable it.
|
|
Performance/CaseWhenSplat:
|
|
Enabled: true
|
|
|
|
# Makes code less readable for minor performance increases.
|
|
Performance/Caller:
|
|
Enabled: false
|
|
|
|
# Makes code less readable for minor performance increases.
|
|
Performance/MethodObjectAsBlock:
|
|
Enabled: false
|
|
|
|
Rails:
|
|
# Selectively enable what we want.
|
|
Enabled: false
|
|
# Cannot use ActiveSupport in RuboCops.
|
|
Exclude:
|
|
- "Homebrew/rubocops/**/*"
|
|
|
|
# These relate to ActiveSupport and not other parts of Rails.
|
|
Rails/ActiveSupportAliases:
|
|
Enabled: true
|
|
Rails/Blank:
|
|
Enabled: true
|
|
Rails/CompactBlank:
|
|
Enabled: true
|
|
Rails/Delegate:
|
|
Enabled: false # TODO
|
|
Rails/DelegateAllowBlank:
|
|
Enabled: true
|
|
Rails/DurationArithmetic:
|
|
Enabled: true
|
|
Rails/ExpandedDateRange:
|
|
Enabled: true
|
|
Rails/Inquiry:
|
|
Enabled: true
|
|
Rails/NegateInclude:
|
|
Enabled: true
|
|
Rails/PluralizationGrammar:
|
|
Enabled: true
|
|
Rails/Presence:
|
|
Enabled: true
|
|
Rails/Present:
|
|
Enabled: true
|
|
Rails/RelativeDateConstant:
|
|
Enabled: true
|
|
Rails/SafeNavigation:
|
|
Enabled: true
|
|
Rails/SafeNavigationWithBlank:
|
|
Enabled: true
|
|
Rails/StripHeredoc:
|
|
Enabled: true
|
|
Rails/ToFormattedS:
|
|
Enabled: true
|
|
|
|
# Don't allow cops to be disabled in casks and formulae.
|
|
Style/DisableCopsWithinSourceCodeDirective:
|
|
Enabled: true
|
|
Include:
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/{Formula,Casks}/*.rb"
|
|
- "**/{Formula,Casks}/*.rb"
|
|
|
|
# make our hashes consistent
|
|
Layout/HashAlignment:
|
|
EnforcedHashRocketStyle: table
|
|
EnforcedColonStyle: table
|
|
|
|
# `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
|
|
|
|
# Need to allow #: for external commands.
|
|
Layout/LeadingCommentSpace:
|
|
Exclude:
|
|
- "Taps/*/*/cmd/*.rb"
|
|
|
|
# this is a bit less "floaty"
|
|
Layout/EndAlignment:
|
|
EnforcedStyleAlignWith: start_of_line
|
|
|
|
# conflicts with DSL-style path concatenation with `/`
|
|
Layout/SpaceAroundOperators:
|
|
Enabled: false
|
|
|
|
# layout is not configurable (https://github.com/rubocop-hq/rubocop/issues/6254).
|
|
Layout/RescueEnsureAlignment:
|
|
Enabled: false
|
|
|
|
# significantly less indentation involved; more consistent
|
|
Layout/FirstArrayElementIndentation:
|
|
EnforcedStyle: consistent
|
|
Layout/FirstHashElementIndentation:
|
|
EnforcedStyle: consistent
|
|
|
|
# favour parens-less DSL-style arguments
|
|
Lint/AmbiguousBlockAssociation:
|
|
Enabled: false
|
|
|
|
Lint/RequireRelativeSelfPath:
|
|
# bugged on formula-analytics
|
|
# https://github.com/Homebrew/brew/pull/12152/checks?check_run_id=3755137378#step:15:60
|
|
Exclude:
|
|
- "Taps/homebrew/homebrew-formula-analytics/*/*.rb"
|
|
|
|
Lint/DuplicateBranch:
|
|
Exclude:
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/{Formula,Casks}/*.rb"
|
|
- "**/{Formula,Casks}/*.rb"
|
|
|
|
# needed for lazy_object magic
|
|
Naming/MemoizedInstanceVariableName:
|
|
Exclude:
|
|
- "Homebrew/lazy_object.rb"
|
|
|
|
# useful for metaprogramming in RSpec
|
|
Lint/ConstantDefinitionInBlock:
|
|
Exclude:
|
|
- "**/*_spec.rb"
|
|
|
|
# so many of these in formulae and can't be autocorrected
|
|
Lint/ParenthesesAsGroupedExpression:
|
|
Exclude:
|
|
- "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"
|
|
Metrics/BlockLength:
|
|
Exclude:
|
|
- "Taps/**/*"
|
|
- "/**/{Formula,Casks}/*.rb"
|
|
- "**/{Formula,Casks}/*.rb"
|
|
Metrics/ClassLength:
|
|
Exclude:
|
|
- "Taps/**/*"
|
|
- "/**/{Formula,Casks}/*.rb"
|
|
- "**/{Formula,Casks}/*.rb"
|
|
Metrics/CyclomaticComplexity:
|
|
Exclude:
|
|
- "Taps/**/*"
|
|
- "/**/{Formula,Casks}/*.rb"
|
|
- "**/{Formula,Casks}/*.rb"
|
|
Metrics/MethodLength:
|
|
Exclude:
|
|
- "Taps/**/*"
|
|
- "/**/{Formula,Casks}/*.rb"
|
|
- "**/{Formula,Casks}/*.rb"
|
|
Metrics/ModuleLength:
|
|
Exclude:
|
|
- "Taps/**/*"
|
|
- "/**/{Formula,Casks}/*.rb"
|
|
- "**/{Formula,Casks}/*.rb"
|
|
Metrics/PerceivedComplexity:
|
|
Exclude:
|
|
- "Taps/**/*"
|
|
- "/**/{Formula,Casks}/*.rb"
|
|
- "**/{Formula,Casks}/*.rb"
|
|
|
|
# allow those that are standard
|
|
# TODO: try to remove some of these
|
|
Naming/MethodParameterName:
|
|
inherit_mode:
|
|
merge:
|
|
- AllowedNames
|
|
AllowedNames:
|
|
- "a"
|
|
- "b"
|
|
- "cc"
|
|
- "c1"
|
|
- "c2"
|
|
- "d"
|
|
- "e"
|
|
- "f"
|
|
- "ff"
|
|
- "fn"
|
|
- "id"
|
|
- "o"
|
|
- "p"
|
|
- "pr"
|
|
- "r"
|
|
- "rb"
|
|
- "s"
|
|
- "v"
|
|
|
|
# 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",
|
|
]
|
|
|
|
Sorbet/FalseSigil:
|
|
Exclude:
|
|
- "Taps/**/*"
|
|
- "/**/{Formula,Casks}/*.rb"
|
|
- "**/{Formula,Casks}/*.rb"
|
|
- "Homebrew/test/**/Casks/**/*.rb"
|
|
|
|
Sorbet/StrictSigil:
|
|
inherit_mode:
|
|
override:
|
|
- Include
|
|
Enabled: true
|
|
Include:
|
|
- "**/*.rbi"
|
|
|
|
# Try getting rid of these.
|
|
Sorbet/ConstantsFromStrings:
|
|
Enabled: false
|
|
|
|
# Avoid false positives on modifiers used on symbols of methods
|
|
# See https://github.com/rubocop-hq/rubocop/issues/5953
|
|
Style/AccessModifierDeclarations:
|
|
Enabled: false
|
|
|
|
# Conflicts with type signatures on `attr_*`s.
|
|
Style/AccessorGrouping:
|
|
Enabled: false
|
|
|
|
# make rspec formatting more flexible
|
|
Style/BlockDelimiters:
|
|
Exclude:
|
|
- "Homebrew/**/*_spec.rb"
|
|
- "Homebrew/**/shared_examples/**/*.rb"
|
|
|
|
# TODO: remove this when possible.
|
|
Style/ClassVars:
|
|
Exclude:
|
|
- "**/developer/bin/*"
|
|
|
|
# Don't enforce documentation in casks or formulae.
|
|
Style/Documentation:
|
|
Exclude:
|
|
- "Taps/**/*"
|
|
- "/**/{Formula,Casks}/*.rb"
|
|
- "**/{Formula,Casks}/*.rb"
|
|
- "**/*.rbi"
|
|
|
|
Style/DocumentationMethod:
|
|
Include:
|
|
- "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"
|
|
|
|
# TODO: remove this when possible.
|
|
Style/GlobalVars:
|
|
Exclude:
|
|
- "**/developer/bin/*"
|
|
|
|
# potential for errors in formulae too high with this
|
|
Style/GuardClause:
|
|
Exclude:
|
|
- "Taps/*/*/*.rb"
|
|
- "/**/{Formula,Casks}/*.rb"
|
|
- "**/{Formula,Casks}/*.rb"
|
|
|
|
# avoid hash rockets where possible
|
|
Style/HashSyntax:
|
|
EnforcedStyle: ruby19
|
|
|
|
# OpenStruct is a nice helper.
|
|
Style/OpenStructUse:
|
|
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
|
|
|
|
# make things a bit easier to read
|
|
Style/TernaryParentheses:
|
|
EnforcedStyle: require_parentheses_when_complex
|
|
|
|
# `unless ... ||` and `unless ... &&` are hard to mentally parse
|
|
Style/UnlessLogicalOperators:
|
|
Enabled: true
|
|
EnforcedStyle: forbid_logical_operators
|
|
|
|
# a bit confusing to non-Rubyists but useful for longer arrays
|
|
Style/WordArray:
|
|
MinSize: 4
|
|
|
|
# would rather freeze too much than too little
|
|
Style/MutableConstant:
|
|
EnforcedStyle: strict
|
|
|
|
# unused keyword arguments improve APIs
|
|
Lint/UnusedMethodArgument:
|
|
AllowUnusedKeywordArguments: true
|