mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Move RuboCop rules into top-level .rubocop.yml
.
This commit is contained in:
parent
2b029b2744
commit
21d57a0c44
@ -2,11 +2,19 @@
|
|||||||
|
|
||||||
require: ./Homebrew/rubocops.rb
|
require: ./Homebrew/rubocops.rb
|
||||||
|
|
||||||
|
inherit_mode:
|
||||||
|
merge:
|
||||||
|
- Include
|
||||||
|
- Exclude
|
||||||
|
|
||||||
AllCops:
|
AllCops:
|
||||||
TargetRubyVersion: 2.6
|
TargetRubyVersion: 2.6
|
||||||
DisplayCopNames: false
|
DisplayCopNames: false
|
||||||
# enable all pending rubocops
|
# enable all pending rubocops
|
||||||
NewCops: enable
|
NewCops: enable
|
||||||
|
Exclude:
|
||||||
|
- 'Homebrew/bin/*'
|
||||||
|
- 'Homebrew/**/vendor/**/*'
|
||||||
|
|
||||||
Cask/Desc:
|
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.'
|
||||||
@ -44,10 +52,6 @@ FormulaAuditStrict:
|
|||||||
Layout/HeredocIndentation:
|
Layout/HeredocIndentation:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
|
||||||
# Not useful in casks and formulae.
|
|
||||||
Metrics/BlockLength:
|
|
||||||
Enabled: false
|
|
||||||
|
|
||||||
# Keyword arguments don't have the same readability
|
# Keyword arguments don't have the same readability
|
||||||
# problems as normal parameters.
|
# problems as normal parameters.
|
||||||
Metrics/ParameterLists:
|
Metrics/ParameterLists:
|
||||||
@ -94,7 +98,8 @@ Style/HashTransformValues:
|
|||||||
|
|
||||||
# Allow for license expressions
|
# Allow for license expressions
|
||||||
Style/HashAsLastArrayItem:
|
Style/HashAsLastArrayItem:
|
||||||
Enabled: false
|
Exclude:
|
||||||
|
- 'Taps/*/*/{Formula/,}*.rb'
|
||||||
|
|
||||||
# Enabled now LineLength is lowish.
|
# Enabled now LineLength is lowish.
|
||||||
Style/IfUnlessModifier:
|
Style/IfUnlessModifier:
|
||||||
@ -147,18 +152,21 @@ Performance/CaseWhenSplat:
|
|||||||
Performance/Caller:
|
Performance/Caller:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
# don't allow cops to be disabled in formulae
|
# Don't allow cops to be disabled in casks and formulae.
|
||||||
Style/DisableCopsWithinSourceCodeDirective:
|
Style/DisableCopsWithinSourceCodeDirective:
|
||||||
Enabled: true
|
Enabled: true
|
||||||
|
Include:
|
||||||
|
- 'Taps/*/*/{Formula/,Casks/,}*.rb'
|
||||||
|
|
||||||
# make our hashes consistent
|
# make our hashes consistent
|
||||||
Layout/HashAlignment:
|
Layout/HashAlignment:
|
||||||
EnforcedHashRocketStyle: table
|
EnforcedHashRocketStyle: table
|
||||||
EnforcedColonStyle: table
|
EnforcedColonStyle: table
|
||||||
|
|
||||||
# `system` is a special case and aligns on second argument
|
# `system` is a special case and aligns on second argument, so allow this for formulae.
|
||||||
Layout/ArgumentAlignment:
|
Layout/ArgumentAlignment:
|
||||||
Enabled: false
|
Exclude:
|
||||||
|
- 'Taps/*/*/{Formula/,}*.rb'
|
||||||
|
|
||||||
# this is a bit less "floaty"
|
# this is a bit less "floaty"
|
||||||
Layout/CaseIndentation:
|
Layout/CaseIndentation:
|
||||||
@ -183,25 +191,62 @@ Lint/AmbiguousBlockAssociation:
|
|||||||
# so many of these in formulae and can't be autocorrected
|
# so many of these in formulae and can't be autocorrected
|
||||||
# TODO: fix these as `ruby -w` complains about them.
|
# TODO: fix these as `ruby -w` complains about them.
|
||||||
Lint/AmbiguousRegexpLiteral:
|
Lint/AmbiguousRegexpLiteral:
|
||||||
Enabled: false
|
Exclude:
|
||||||
|
- 'Taps/*/*/{Formula/,}*.rb'
|
||||||
|
|
||||||
# so many of these in formulae and can't be autocorrected
|
# so many of these in formulae and can't be autocorrected
|
||||||
Lint/ParenthesesAsGroupedExpression:
|
Lint/ParenthesesAsGroupedExpression:
|
||||||
Enabled: false
|
Exclude:
|
||||||
|
- 'Taps/*/*/{Formula/,}*.rb'
|
||||||
|
|
||||||
# most metrics don't make sense to apply for formulae/taps
|
# Most metrics don't make sense to apply for casks/formulae/taps.
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Enabled: false
|
Exclude:
|
||||||
|
- 'Taps/**/*'
|
||||||
|
Metrics/BlockLength:
|
||||||
|
Exclude:
|
||||||
|
- 'Taps/**/*'
|
||||||
Metrics/ClassLength:
|
Metrics/ClassLength:
|
||||||
Enabled: false
|
Exclude:
|
||||||
|
- 'Taps/**/*'
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Enabled: false
|
Exclude:
|
||||||
|
- 'Taps/**/*'
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Enabled: false
|
Exclude:
|
||||||
|
- 'Taps/**/*'
|
||||||
Metrics/ModuleLength:
|
Metrics/ModuleLength:
|
||||||
Enabled: false
|
Exclude:
|
||||||
|
- 'Taps/**/*'
|
||||||
Metrics/PerceivedComplexity:
|
Metrics/PerceivedComplexity:
|
||||||
Enabled: false
|
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'
|
||||||
|
|
||||||
# GitHub diff UI wraps beyond 118 characters
|
# GitHub diff UI wraps beyond 118 characters
|
||||||
Layout/LineLength:
|
Layout/LineLength:
|
||||||
@ -214,6 +259,27 @@ Layout/LineLength:
|
|||||||
' "~/Library/Application Support/', '"~/Library/Caches/', '"~/Application Support',
|
' "~/Library/Application Support/', '"~/Library/Caches/', '"~/Application Support',
|
||||||
' was verified as official when first introduced to the cask']
|
' was verified as official when first introduced to the cask']
|
||||||
|
|
||||||
|
# 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'
|
||||||
|
|
||||||
# TODO: remove this when possible.
|
# TODO: remove this when possible.
|
||||||
Style/ClassVars:
|
Style/ClassVars:
|
||||||
Exclude:
|
Exclude:
|
||||||
@ -221,11 +287,18 @@ Style/ClassVars:
|
|||||||
|
|
||||||
# Don't enforce documentation in casks or formulae.
|
# Don't enforce documentation in casks or formulae.
|
||||||
Style/Documentation:
|
Style/Documentation:
|
||||||
Enabled: false
|
Exclude:
|
||||||
|
- 'Taps/**/*'
|
||||||
|
|
||||||
|
Style/DocumentationMethod:
|
||||||
|
Include:
|
||||||
|
- 'Homebrew/formula.rb'
|
||||||
|
|
||||||
# Not used for casks and formulae.
|
# Not used for casks and formulae.
|
||||||
Style/FrozenStringLiteralComment:
|
Style/FrozenStringLiteralComment:
|
||||||
Enabled: false
|
EnforcedStyle: always
|
||||||
|
Exclude:
|
||||||
|
- 'Taps/*/*/{Formula/,Casks/,}*.rb'
|
||||||
|
|
||||||
# TODO: remove this when possible.
|
# TODO: remove this when possible.
|
||||||
Style/GlobalVars:
|
Style/GlobalVars:
|
||||||
@ -234,7 +307,8 @@ Style/GlobalVars:
|
|||||||
|
|
||||||
# potential for errors in formulae too high with this
|
# potential for errors in formulae too high with this
|
||||||
Style/GuardClause:
|
Style/GuardClause:
|
||||||
Enabled: false
|
Exclude:
|
||||||
|
- 'Taps/*/*/{Formula/,Casks/,}*.rb'
|
||||||
|
|
||||||
# avoid hash rockets where possible
|
# avoid hash rockets where possible
|
||||||
Style/HashSyntax:
|
Style/HashSyntax:
|
||||||
@ -242,7 +316,8 @@ Style/HashSyntax:
|
|||||||
|
|
||||||
# so many of these in formulae and can't be autocorrected
|
# so many of these in formulae and can't be autocorrected
|
||||||
Style/StringConcatenation:
|
Style/StringConcatenation:
|
||||||
Enabled: false
|
Exclude:
|
||||||
|
- 'Taps/*/*/{Formula/,Casks/,}*.rb'
|
||||||
|
|
||||||
# ruby style guide favorite
|
# ruby style guide favorite
|
||||||
Style/StringLiterals:
|
Style/StringLiterals:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# TODO: This file can be deleted once https://github.com/Homebrew/brew/pull/8542
|
# TODO: This file can be deleted once https://github.com/Homebrew/brew/pull/8542
|
||||||
# is in a stable release and `rubocop.yml` has been removed from all cask taps.
|
# is in a stable release and `rubocop.yml` has been removed from all cask taps.
|
||||||
|
|
||||||
inherit_from: ./Homebrew/.rubocop.yml
|
inherit_from: ./.rubocop.yml
|
||||||
|
@ -2,27 +2,11 @@ inherit_from:
|
|||||||
- ../.rubocop_rspec.yml
|
- ../.rubocop_rspec.yml
|
||||||
- .rubocop_todo.yml
|
- .rubocop_todo.yml
|
||||||
|
|
||||||
AllCops:
|
|
||||||
Include:
|
|
||||||
- '**/*.rb'
|
|
||||||
- 'Library/Homebrew/.simplecov'
|
|
||||||
Exclude:
|
|
||||||
- 'bin/*'
|
|
||||||
- '**/vendor/**/*'
|
|
||||||
|
|
||||||
# messes up system formatting for formulae but good for Homebrew/brew
|
|
||||||
Layout/ArgumentAlignment:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
# make rspec formatting more flexible
|
# make rspec formatting more flexible
|
||||||
Layout/MultilineMethodCallIndentation:
|
Layout/MultilineMethodCallIndentation:
|
||||||
Exclude:
|
Exclude:
|
||||||
- '**/*_spec.rb'
|
- '**/*_spec.rb'
|
||||||
|
|
||||||
# so many of these in formulae but none in here
|
|
||||||
Lint/AmbiguousRegexpLiteral:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
# TODO: add parentheses for these and remove
|
# TODO: add parentheses for these and remove
|
||||||
Lint/AssignmentInCondition:
|
Lint/AssignmentInCondition:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
@ -32,123 +16,39 @@ Lint/NestedMethodDefinition:
|
|||||||
Exclude:
|
Exclude:
|
||||||
- 'test/**/*'
|
- 'test/**/*'
|
||||||
|
|
||||||
# so many of these in formulae but none in here
|
# TODO: Try to bring down all metrics maximums.
|
||||||
Lint/ParenthesesAsGroupedExpression:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
# TODO: try to bring down all metrics maximums
|
|
||||||
Metrics/AbcSize:
|
Metrics/AbcSize:
|
||||||
Enabled: true
|
|
||||||
Max: 250
|
Max: 250
|
||||||
Metrics/BlockLength:
|
Metrics/BlockLength:
|
||||||
Enabled: true
|
|
||||||
Max: 100
|
Max: 100
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'test/**/*'
|
- 'test/**/*'
|
||||||
Metrics/BlockNesting:
|
Metrics/BlockNesting:
|
||||||
Enabled: true
|
|
||||||
Max: 5
|
Max: 5
|
||||||
Metrics/ClassLength:
|
Metrics/ClassLength:
|
||||||
Enabled: true
|
|
||||||
Max: 800
|
Max: 800
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'formula.rb'
|
- 'formula.rb'
|
||||||
- 'formula_installer.rb'
|
- 'formula_installer.rb'
|
||||||
Metrics/CyclomaticComplexity:
|
Metrics/CyclomaticComplexity:
|
||||||
Enabled: true
|
|
||||||
Max: 80
|
Max: 80
|
||||||
|
Metrics/PerceivedComplexity:
|
||||||
|
Max: 90
|
||||||
Metrics/MethodLength:
|
Metrics/MethodLength:
|
||||||
Enabled: true
|
|
||||||
Max: 260
|
Max: 260
|
||||||
Metrics/ModuleLength:
|
Metrics/ModuleLength:
|
||||||
Enabled: true
|
|
||||||
Max: 600
|
Max: 600
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'test/**/*'
|
- 'test/**/*'
|
||||||
Metrics/PerceivedComplexity:
|
|
||||||
Enabled: true
|
|
||||||
Max: 90
|
|
||||||
|
|
||||||
# we won't change backward compatible predicate names
|
|
||||||
Naming/PredicateName:
|
Naming/PredicateName:
|
||||||
Exclude:
|
# Can't rename these.
|
||||||
- 'compat/**/*'
|
|
||||||
# can't rename these
|
|
||||||
AllowedMethods: is_32_bit?, is_64_bit?
|
AllowedMethods: is_32_bit?, is_64_bit?
|
||||||
|
|
||||||
# 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'
|
|
||||||
|
|
||||||
# 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:
|
|
||||||
- 'formula.rb'
|
|
||||||
- 'formulary.rb'
|
|
||||||
- 'migrator.rb'
|
|
||||||
- 'resource.rb'
|
|
||||||
- 'system_command.rb'
|
|
||||||
- 'tap.rb'
|
|
||||||
|
|
||||||
# make rspec formatting more flexible
|
|
||||||
Style/BlockDelimiters:
|
|
||||||
Exclude:
|
|
||||||
- '**/*_spec.rb'
|
|
||||||
- '**/shared_examples/**/*.rb'
|
|
||||||
|
|
||||||
# document our public APIs
|
|
||||||
Style/Documentation:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
Style/DocumentationMethod:
|
|
||||||
Enabled: true
|
|
||||||
Include:
|
|
||||||
- 'formula.rb'
|
|
||||||
|
|
||||||
# don't want this for formulae but re-enabled for Library/Homebrew
|
|
||||||
Style/FrozenStringLiteralComment:
|
Style/FrozenStringLiteralComment:
|
||||||
Enabled: true
|
|
||||||
EnforcedStyle: always
|
|
||||||
Exclude:
|
Exclude:
|
||||||
- '**/Casks/**/*.rb'
|
- '**/Casks/**/*.rb'
|
||||||
|
|
||||||
# so many of these in formulae but none in here
|
|
||||||
Style/GuardClause:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
# so many of these in formulae but none in here
|
|
||||||
Style/StringConcatenation:
|
|
||||||
Enabled: true
|
|
||||||
|
|
||||||
# don't want this for formulae but re-enabled for Library/Homebrew
|
|
||||||
Style/HashAsLastArrayItem:
|
Style/HashAsLastArrayItem:
|
||||||
Enabled: true
|
|
||||||
Exclude:
|
Exclude:
|
||||||
- 'test/utils/spdx_spec.rb'
|
- 'test/utils/spdx_spec.rb'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user