2020-07-27 12:57:29 +01:00
# TODO: Try getting more rules in sync.
require : ./Homebrew/rubocops.rb
2020-08-31 02:02:05 +02:00
inherit_mode :
merge :
- Include
- Exclude
2020-07-27 12:57:29 +01:00
AllCops :
TargetRubyVersion : 2.6
DisplayCopNames : false
# enable all pending rubocops
NewCops : enable
2020-10-10 19:29:49 +02:00
Include :
- '**/*.rbi'
2020-08-31 02:02:05 +02:00
Exclude :
2020-10-10 19:29:49 +02:00
- 'Homebrew/sorbet/rbi/gems/**/*.rbi'
- 'Homebrew/sorbet/rbi/hidden-definitions/**/*.rbi'
- 'Homebrew/sorbet/rbi/todo.rbi'
2020-08-31 02:02:05 +02:00
- 'Homebrew/bin/*'
2020-08-31 04:24:43 +02:00
- 'Homebrew/vendor/**/*'
2017-01-18 15:54:47 +05:30
2020-08-31 00:13:15 +02:00
Cask/Desc :
Description : 'Ensure that the desc stanza conforms to various content and style checks.'
Enabled : true
Cask/HomepageMatchesUrl :
Description : 'Ensure that the homepage and url match, otherwise add a comment. More info at https://github.com/Homebrew/homebrew-cask/blob/HEAD/doc/cask_language_reference/stanzas/url.md#when-url-and-homepage-hostnames-differ-add-a-comment'
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://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'
Enabled : true
2018-09-02 20:14:54 +01:00
# enable all formulae audits
2017-07-18 19:10:12 +05:30
FormulaAudit :
2017-05-24 00:08:31 +05:30
Enabled : true
2018-09-02 20:14:54 +01:00
# enable all formulae strict audits
2017-07-18 19:10:12 +05:30
FormulaAuditStrict :
2017-05-22 13:09:49 +05:30
Enabled : true
2020-07-27 12:57:29 +01:00
# Use `<<~` for heredocs.
Layout/HeredocIndentation :
Enabled : true
# 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
2020-10-10 19:29:49 +02:00
Naming/MethodName :
IgnoredPatterns :
- '\AHEAD\?\Z'
2020-07-27 12:57:29 +01:00
# 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
2020-08-18 10:58:32 -04:00
# Allow for license expressions
Style/HashAsLastArrayItem :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/*/*/{Formula/,}*.rb'
2020-08-18 10:58:32 -04:00
2020-07-27 12:57:29 +01:00
# 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
2020-04-17 10:21:10 +01:00
2020-08-31 02:02:05 +02:00
# Don't allow cops to be disabled in casks and formulae.
2020-04-17 10:21:10 +01:00
Style/DisableCopsWithinSourceCodeDirective :
Enabled : true
2020-08-31 02:02:05 +02:00
Include :
- 'Taps/*/*/{Formula/,Casks/,}*.rb'
2020-04-17 10:21:10 +01:00
2018-11-02 17:17:35 +00:00
# make our hashes consistent
2019-11-28 15:10:50 +00:00
Layout/HashAlignment :
2018-11-02 17:17:35 +00:00
EnforcedHashRocketStyle : table
EnforcedColonStyle : table
2020-08-31 02:02:05 +02:00
# `system` is a special case and aligns on second argument, so allow this for formulae.
2019-11-28 15:10:50 +00:00
Layout/ArgumentAlignment :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/*/*/{Formula/,}*.rb'
2016-09-25 02:41:14 +02:00
2018-09-02 20:14:54 +01:00
# this is a bit less "floaty"
2017-05-28 16:59:53 +01:00
Layout/CaseIndentation :
EnforcedStyle : end
2016-09-18 14:27:09 +01:00
2018-09-02 20:14:54 +01:00
# this is a bit less "floaty"
2018-03-05 11:46:38 +00:00
Layout/EndAlignment :
2018-09-02 20:14:54 +01:00
EnforcedStyleAlignWith : start_of_line
2016-09-25 02:41:14 +02:00
2017-05-28 16:59:53 +01:00
# conflicts with DSL-style path concatenation with `/`
Layout/SpaceAroundOperators :
2016-09-18 14:27:09 +01:00
Enabled : false
2020-03-13 21:14:24 +00:00
# layout is not configurable (https://github.com/rubocop-hq/rubocop/issues/6254).
2018-09-18 10:30:59 +10:00
Layout/RescueEnsureAlignment :
Enabled : false
2018-09-02 20:14:54 +01:00
# favour parens-less DSL-style arguments
Lint/AmbiguousBlockAssociation :
2016-09-18 14:27:09 +01:00
Enabled : false
2016-09-25 02:41:14 +02:00
2020-11-09 20:03:48 +11:00
# needed for lazy_object magic
Naming/MemoizedInstanceVariableName :
Exclude :
- 'Homebrew/lazy_object.rb'
2017-05-28 16:59:53 +01:00
# so many of these in formulae and can't be autocorrected
2018-09-02 20:14:54 +01:00
# TODO: fix these as `ruby -w` complains about them.
2016-09-18 14:27:09 +01:00
Lint/AmbiguousRegexpLiteral :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/*/*/{Formula/,}*.rb'
2016-09-25 02:41:14 +02:00
2020-09-15 13:39:06 +01:00
# useful for metaprogramming in RSpec
Lint/ConstantDefinitionInBlock :
Exclude :
- '**/*_spec.rb'
2017-05-28 16:59:53 +01:00
# so many of these in formulae and can't be autocorrected
2016-09-18 14:27:09 +01:00
Lint/ParenthesesAsGroupedExpression :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/*/*/{Formula/,}*.rb'
2016-09-18 14:27:09 +01:00
2020-08-31 02:02:05 +02:00
# Most metrics don't make sense to apply for casks/formulae/taps.
2017-05-28 16:59:53 +01:00
Metrics/AbcSize :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/**/*'
Metrics/BlockLength :
Exclude :
- 'Taps/**/*'
2017-05-28 16:59:53 +01:00
Metrics/ClassLength :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/**/*'
2017-05-28 16:59:53 +01:00
Metrics/CyclomaticComplexity :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/**/*'
2018-09-02 20:14:54 +01:00
Metrics/MethodLength :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/**/*'
2018-12-03 13:23:20 +01:00
Metrics/ModuleLength :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/**/*'
2018-09-02 20:14:54 +01:00
Metrics/PerceivedComplexity :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/**/*'
# 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'
2018-09-02 20:14:54 +01:00
2020-03-12 20:39:15 +00:00
# GitHub diff UI wraps beyond 118 characters
2019-12-19 12:01:51 +00:00
Layout/LineLength :
2020-03-12 20:39:15 +00:00
Max : 118
2017-10-26 16:06:29 +01:00
# ignore manpage comments and long single-line strings
2020-07-27 12:57:29 +01:00
IgnoredPatterns: ['# : ', ' url "', ' mirror "', ' plist_options ',
2020-07-30 22:10:53 +08:00
' appcast "' , ' executable : "', ' font " ', ' homepage "', ' name "',
' pkg "' , ' pkgutil : "', '#{language}', '#{version.',
' "/Library/Application Support/' , '"/Library/Caches/' , '"/Library/PreferencePanes/' ,
2020-07-27 12:57:29 +01:00
' "~/Library/Application Support/' , '"~/Library/Caches/' , '"~/Application Support' ,
' was verified as official when first introduced to the cask' ]
2020-09-20 05:57:37 +02:00
Sorbet/FalseSigil :
2020-10-10 19:29:49 +02:00
Exclude :
- 'Taps/**/*.rb'
- 'Homebrew/test/**/Casks/**/*.rb'
Sorbet/StrictSigil :
2020-10-20 00:56:50 +02:00
Enabled : true
2020-10-10 19:29:49 +02:00
Include :
- '**/*.rbi'
2020-09-20 05:57:37 +02:00
# Try getting rid of these.
Sorbet/ConstantsFromStrings :
Enabled : false
2020-08-31 02:02:05 +02:00
# Avoid false positives on modifiers used on symbols of methods
# See https://github.com/rubocop-hq/rubocop/issues/5953
Style/AccessModifierDeclarations :
Enabled : false
# don't group nicely documented or private attr_readers
Style/AccessorGrouping :
Exclude :
- 'Homebrew/formula.rb'
- 'Homebrew/formulary.rb'
- 'Homebrew/migrator.rb'
- 'Homebrew/resource.rb'
- 'Homebrew/system_command.rb'
- 'Homebrew/tap.rb'
# make rspec formatting more flexible
Style/BlockDelimiters :
Exclude :
- 'Homebrew/**/*_spec.rb'
- 'Homebrew/**/shared_examples/**/*.rb'
2020-07-27 12:57:29 +01:00
# TODO: remove this when possible.
Style/ClassVars :
Exclude :
- '**/developer/bin/*'
2016-09-25 02:41:14 +02:00
2020-08-31 00:13:15 +02:00
# Don't enforce documentation in casks or formulae.
2016-09-25 02:41:14 +02:00
Style/Documentation :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/**/*'
2020-10-10 19:29:49 +02:00
- '**/*.rbi'
2020-08-31 02:02:05 +02:00
Style/DocumentationMethod :
Include :
- 'Homebrew/formula.rb'
2016-09-25 02:41:14 +02:00
2020-08-31 00:13:15 +02:00
# Not used for casks and formulae.
2018-09-02 20:14:54 +01:00
Style/FrozenStringLiteralComment :
2020-08-31 02:02:05 +02:00
EnforcedStyle : always
Exclude :
2020-09-01 02:51:25 +02:00
- 'Taps/*/*/{Formula,Casks,}/*.rb'
- 'Homebrew/test/**/Casks/**/*.rb'
2020-10-10 19:29:49 +02:00
- '**/*.rbi'
2017-05-28 16:59:53 +01:00
2020-07-27 12:57:29 +01:00
# TODO: remove this when possible.
Style/GlobalVars :
Exclude :
- '**/developer/bin/*'
2020-03-13 21:14:24 +00:00
# potential for errors in formulae too high with this
2016-10-01 12:13:09 +01:00
Style/GuardClause :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/*/*/{Formula/,Casks/,}*.rb'
2016-10-01 12:13:09 +01:00
2020-07-27 12:57:29 +01:00
# avoid hash rockets where possible
2016-10-01 12:13:09 +01:00
Style/HashSyntax :
2020-07-27 12:57:29 +01:00
EnforcedStyle : ruby19
2020-03-13 21:14:24 +00:00
2020-08-19 17:12:32 +01:00
# so many of these in formulae and can't be autocorrected
Style/StringConcatenation :
2020-08-31 02:02:05 +02:00
Exclude :
- 'Taps/*/*/{Formula/,Casks/,}*.rb'
2020-08-19 17:12:32 +01:00
2016-09-25 02:41:14 +02:00
# ruby style guide favorite
Style/StringLiterals :
EnforcedStyle : double_quotes
2016-09-18 14:27:09 +01:00
2016-09-25 02:41:14 +02:00
# consistency with above
Style/StringLiteralsInInterpolation :
EnforcedStyle : double_quotes
2017-05-28 16:59:53 +01:00
2018-09-02 20:14:54 +01:00
# make things a bit easier to read
2016-09-21 15:14:15 +02:00
Style/TernaryParentheses :
2017-05-28 16:59:53 +01:00
EnforcedStyle : require_parentheses_when_complex
2016-09-21 15:14:15 +02:00
2018-09-02 20:14:54 +01:00
# a bit confusing to non-Rubyists but useful for longer arrays
2016-09-25 02:41:14 +02:00
Style/WordArray :
2017-05-28 16:59:53 +01:00
MinSize : 4
2020-07-27 12:57:29 +01:00
# would rather freeze too much than too little
Style/MutableConstant :
EnforcedStyle : strict
# unused keyword arguments improve APIs
Lint/UnusedMethodArgument :
AllowUnusedKeywordArguments : true