Make the Homebrew/cask and Homebrew/homebrew-core style more closely match the rest of Homebrew. To accomplish this: - Run `brew cask style` to ensure we don't break style there when making changes or upgrading RuboCop in Homebrew/brew. - Fix the HomepageMatchesUrl cop to better handle weird input. - Remove the now unneeded `.rubocop_shared.yml` - Fix the cask fixtures with `brew cask style --fix`. - Share more style between Homebrew/brew, casks and formulae.
237 lines
5.6 KiB
YAML
237 lines
5.6 KiB
YAML
# TODO: Try getting more rules in sync.
|
|
|
|
require: ./Homebrew/rubocops.rb
|
|
|
|
AllCops:
|
|
TargetRubyVersion: 2.6
|
|
DisplayCopNames: false
|
|
# enable all pending rubocops
|
|
NewCops: enable
|
|
|
|
# enable all formulae audits
|
|
FormulaAudit:
|
|
Enabled: true
|
|
|
|
# enable all formulae strict audits
|
|
FormulaAuditStrict:
|
|
Enabled: true
|
|
|
|
# Use `<<~` for heredocs.
|
|
Layout/HeredocIndentation:
|
|
Enabled: true
|
|
|
|
# Not useful in casks and formulae.
|
|
Metrics/BlockLength:
|
|
Enabled: false
|
|
|
|
# Keyword arguments don't have the same readability
|
|
# problems as normal parameters.
|
|
Metrics/ParameterLists:
|
|
CountKeywordArgs: false
|
|
|
|
# Implicitly allow EOS as we use it everywhere.
|
|
Naming/HeredocDelimiterNaming:
|
|
ForbiddenDelimiters:
|
|
- END, EOD, EOF
|
|
|
|
# Allow dashes in filenames.
|
|
Naming/FileName:
|
|
Regex: !ruby/regexp /^[\w\@\-\+\.]+(\.rb)?$/
|
|
|
|
# Both styles are used depending on context,
|
|
# e.g. `sha256` and `something_countable_1`.
|
|
Naming/VariableNumber:
|
|
Enabled: false
|
|
|
|
# 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
|
|
|
|
# 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
|
|
|
|
# Enabled now LineLength is lowish.
|
|
Style/IfUnlessModifier:
|
|
Enabled: true
|
|
|
|
# Only use this for numbers >= `1_000_000`.
|
|
Style/NumericLiterals:
|
|
MinDigits: 7
|
|
Strict: true
|
|
|
|
# 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
|
|
|
|
# don't allow cops to be disabled in formulae
|
|
Style/DisableCopsWithinSourceCodeDirective:
|
|
Enabled: true
|
|
|
|
# make our hashes consistent
|
|
Layout/HashAlignment:
|
|
EnforcedHashRocketStyle: table
|
|
EnforcedColonStyle: table
|
|
|
|
# `system` is a special case and aligns on second argument
|
|
Layout/ArgumentAlignment:
|
|
Enabled: false
|
|
|
|
# this is a bit less "floaty"
|
|
Layout/CaseIndentation:
|
|
EnforcedStyle: end
|
|
|
|
# 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
|
|
|
|
# favour parens-less DSL-style arguments
|
|
Lint/AmbiguousBlockAssociation:
|
|
Enabled: false
|
|
|
|
# so many of these in formulae and can't be autocorrected
|
|
# TODO: fix these as `ruby -w` complains about them.
|
|
Lint/AmbiguousRegexpLiteral:
|
|
Enabled: false
|
|
|
|
# so many of these in formulae and can't be autocorrected
|
|
Lint/ParenthesesAsGroupedExpression:
|
|
Enabled: false
|
|
|
|
|
|
# most metrics don't make sense to apply for formulae/taps
|
|
Metrics/AbcSize:
|
|
Enabled: false
|
|
Metrics/ClassLength:
|
|
Enabled: false
|
|
Metrics/CyclomaticComplexity:
|
|
Enabled: false
|
|
Metrics/MethodLength:
|
|
Enabled: false
|
|
Metrics/ModuleLength:
|
|
Enabled: false
|
|
Metrics/PerceivedComplexity:
|
|
Enabled: false
|
|
|
|
# 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: "', '#{version.',
|
|
' "~/Library/Application Support/', '"~/Library/Caches/', '"~/Application Support',
|
|
' was verified as official when first introduced to the cask']
|
|
|
|
# TODO: remove this when possible.
|
|
Style/ClassVars:
|
|
Exclude:
|
|
- '**/developer/bin/*'
|
|
|
|
# most of our APIs are internal so don't require docs
|
|
Style/Documentation:
|
|
Enabled: false
|
|
|
|
# don't want this for formulae but re-enabled for Library/Homebrew
|
|
Style/FrozenStringLiteralComment:
|
|
Enabled: false
|
|
|
|
# TODO: remove this when possible.
|
|
Style/GlobalVars:
|
|
Exclude:
|
|
- '**/developer/bin/*'
|
|
|
|
# potential for errors in formulae too high with this
|
|
Style/GuardClause:
|
|
Enabled: false
|
|
|
|
# avoid hash rockets where possible
|
|
Style/HashSyntax:
|
|
EnforcedStyle: ruby19
|
|
|
|
# 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
|
|
|
|
# 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
|