Use parallel RuboCop
This requires updating to Rubocop 0.49.0 which will require some fixes to rules, in Homebrew/brew and Homebrew/homebrew-core but opening this for now so I remember.
This commit is contained in:
parent
3165fd2519
commit
4356016b4a
@ -2,9 +2,9 @@ language: ruby
|
||||
cache:
|
||||
directories:
|
||||
- $HOME/.gem/ruby
|
||||
- $HOME/Library/Caches/Homebrew/style
|
||||
- $HOME/Library/Caches/Homebrew/tests
|
||||
- Library/Homebrew/vendor/bundle
|
||||
# For parallel_rspec
|
||||
- Library/Homebrew/tmp
|
||||
|
||||
matrix:
|
||||
include:
|
||||
|
@ -23,23 +23,67 @@ FormulaAuditStrict/ComponentsRedundancy:
|
||||
FormulaAudit/Homepage:
|
||||
Enabled: true
|
||||
|
||||
Metrics/AbcSize:
|
||||
# `system` is a special case and aligns on second argument
|
||||
Layout/AlignParameters:
|
||||
Enabled: false
|
||||
|
||||
Layout/CaseIndentation:
|
||||
EnforcedStyle: end
|
||||
|
||||
Layout/EmptyLineBetweenDefs:
|
||||
AllowAdjacentOneLineDefs: true
|
||||
|
||||
Layout/IndentArray:
|
||||
EnforcedStyle: special_inside_parentheses
|
||||
|
||||
Layout/IndentHeredoc:
|
||||
EnforcedStyle: unindent
|
||||
|
||||
# conflicts with DSL-style path concatenation with `/`
|
||||
Layout/SpaceAroundOperators:
|
||||
Enabled: false
|
||||
|
||||
# favor parens-less DSL-style arguments
|
||||
Lint/AmbiguousOperator:
|
||||
Enabled: false
|
||||
|
||||
# so many of these in formulae and can't be autocorrected
|
||||
Lint/AmbiguousRegexpLiteral:
|
||||
Enabled: false
|
||||
|
||||
# favor parens-less DSL-style arguments
|
||||
Lint/AmbiguousBlockAssociation:
|
||||
Enabled: false
|
||||
|
||||
# assignment in conditions are useful sometimes
|
||||
Lint/AssignmentInCondition:
|
||||
Enabled: false
|
||||
|
||||
Lint/EndAlignment:
|
||||
EnforcedStyleAlignWith: variable
|
||||
|
||||
# so many of these in formulae and can't be autocorrected
|
||||
Lint/ParenthesesAsGroupedExpression:
|
||||
Enabled: false
|
||||
|
||||
# TODO: try to bring down all metrics maximums
|
||||
Metrics/AbcSize:
|
||||
Max: 250
|
||||
|
||||
Metrics/BlockLength:
|
||||
Enabled: false
|
||||
Max: 1250
|
||||
|
||||
Metrics/ClassLength:
|
||||
Enabled: false
|
||||
Max: 1500
|
||||
|
||||
Metrics/CyclomaticComplexity:
|
||||
Enabled: false
|
||||
Max: 75
|
||||
|
||||
Metrics/LineLength:
|
||||
Enabled: false
|
||||
Max: 400
|
||||
|
||||
Metrics/MethodLength:
|
||||
Enabled: false
|
||||
Max: 250
|
||||
|
||||
Metrics/ModuleLength:
|
||||
CountComments: false
|
||||
@ -47,36 +91,19 @@ Metrics/ModuleLength:
|
||||
- '**/bin/**/*'
|
||||
- '**/cmd/**/*'
|
||||
- '**/lib/**/*'
|
||||
- '**/spec/**/*'
|
||||
|
||||
Metrics/PerceivedComplexity:
|
||||
Enabled: false
|
||||
Max: 80
|
||||
|
||||
# favor parens-less DSL-style arguments
|
||||
Lint/AmbiguousOperator:
|
||||
Enabled: false
|
||||
|
||||
Lint/AmbiguousRegexpLiteral:
|
||||
Enabled: false
|
||||
|
||||
Lint/AssignmentInCondition:
|
||||
Enabled: false
|
||||
|
||||
Lint/EndAlignment:
|
||||
EnforcedStyleAlignWith: variable
|
||||
|
||||
Lint/ParenthesesAsGroupedExpression:
|
||||
# makes code less readable for minor performance increases
|
||||
Performance/Caller:
|
||||
Enabled: false
|
||||
|
||||
Style/Alias:
|
||||
EnforcedStyle: prefer_alias
|
||||
|
||||
Style/AlignHash:
|
||||
Enabled: false
|
||||
|
||||
# `system` is a special case and aligns on second argument
|
||||
Style/AlignParameters:
|
||||
Enabled: false
|
||||
Style/AutoResourceCleanup:
|
||||
Enabled: true
|
||||
|
||||
Style/BarePercentLiterals:
|
||||
EnforcedStyle: percent_q
|
||||
@ -84,9 +111,6 @@ Style/BarePercentLiterals:
|
||||
Style/BlockDelimiters:
|
||||
EnforcedStyle: line_count_based
|
||||
|
||||
Style/CaseIndentation:
|
||||
EnforcedStyle: end
|
||||
|
||||
Style/ClassAndModuleChildren:
|
||||
EnforcedStyle: nested
|
||||
|
||||
@ -99,16 +123,22 @@ Style/CommandLiteral:
|
||||
Style/ConditionalAssignment:
|
||||
Enabled: false
|
||||
|
||||
# most of our APIs are internal so don't require docs
|
||||
Style/Documentation:
|
||||
Enabled: false
|
||||
|
||||
Style/EmptyLineBetweenDefs:
|
||||
AllowAdjacentOneLineDefs: true
|
||||
Style/Encoding:
|
||||
Enabled: true
|
||||
|
||||
# dashes in filenames are typical
|
||||
Style/FileName:
|
||||
Regex: !ruby/regexp /^[\w\@\-\+\.]+(\.rb)?$/
|
||||
|
||||
# falsely flags e.g. curl formatting arguments as format strings
|
||||
Style/FormatStringToken:
|
||||
Enabled: false
|
||||
|
||||
# so many of these in formulae and can't be autocorrected
|
||||
Style/GuardClause:
|
||||
Enabled: false
|
||||
|
||||
@ -121,13 +151,6 @@ Style/HashSyntax:
|
||||
- '**/lib/**/*'
|
||||
- '**/spec/**/*'
|
||||
|
||||
# disabled until it respects line length
|
||||
Style/IfUnlessModifier:
|
||||
Enabled: false
|
||||
|
||||
Style/IndentArray:
|
||||
EnforcedStyle: special_inside_parentheses
|
||||
|
||||
# only for numbers >= 1_000_000
|
||||
Style/NumericLiterals:
|
||||
MinDigits: 7
|
||||
@ -160,13 +183,6 @@ Style/RaiseArgs:
|
||||
Style/RegexpLiteral:
|
||||
EnforcedStyle: slashes
|
||||
|
||||
# conflicts with DSL-style path concatenation with `/`
|
||||
Style/SpaceAroundOperators:
|
||||
Enabled: false
|
||||
|
||||
Style/SingleLineBlockParams:
|
||||
Enabled: false
|
||||
|
||||
# not a problem for typical shell users
|
||||
Style/SpecialGlobalVars:
|
||||
Enabled: false
|
||||
@ -179,17 +195,22 @@ Style/StringLiterals:
|
||||
Style/StringLiteralsInInterpolation:
|
||||
EnforcedStyle: double_quotes
|
||||
|
||||
Style/SymbolArray:
|
||||
EnforcedStyle: brackets
|
||||
|
||||
Style/TernaryParentheses:
|
||||
Enabled: false
|
||||
EnforcedStyle: require_parentheses_when_complex
|
||||
|
||||
# makes diffs nicer
|
||||
Style/TrailingCommaInLiteral:
|
||||
EnforcedStyleForMultiline: comma
|
||||
|
||||
Style/TrailingCommaInArguments:
|
||||
EnforcedStyleForMultiline: comma
|
||||
|
||||
# we have too many variables like sha256 where this harms readability
|
||||
Style/VariableNumber:
|
||||
Enabled: false
|
||||
|
||||
Style/WordArray:
|
||||
Enabled: false
|
||||
MinSize: 4
|
||||
|
@ -9,9 +9,8 @@ AllCops:
|
||||
- '**/Casks/**/*'
|
||||
- '**/vendor/**/*'
|
||||
|
||||
Style/BlockDelimiters:
|
||||
Layout/MultilineMethodCallIndentation:
|
||||
Exclude:
|
||||
- '**/cask/spec/**/*'
|
||||
- '**/*_spec.rb'
|
||||
|
||||
# so many of these in formulae but none in here
|
||||
@ -27,16 +26,13 @@ Lint/NestedMethodDefinition:
|
||||
Lint/ParenthesesAsGroupedExpression:
|
||||
Enabled: true
|
||||
|
||||
Metrics/ModuleLength:
|
||||
CountComments: false
|
||||
Exclude:
|
||||
- 'cask/lib/hbc/locations.rb'
|
||||
- 'cask/lib/hbc/macos.rb'
|
||||
- 'cask/lib/hbc/utils.rb'
|
||||
|
||||
Metrics/ParameterLists:
|
||||
CountKeywordArgs: false
|
||||
|
||||
Style/BlockDelimiters:
|
||||
Exclude:
|
||||
- '**/*_spec.rb'
|
||||
|
||||
# so many of these in formulae but none in here
|
||||
Style/GuardClause:
|
||||
Enabled: true
|
||||
|
@ -11,7 +11,8 @@ module Hbc
|
||||
|
||||
def run
|
||||
install_rubocop
|
||||
system({ "XDG_CACHE_HOME" => HOMEBREW_CACHE }, "rubocop", *rubocop_args, "--", *cask_paths)
|
||||
cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" }
|
||||
system(cache_env, "rubocop", *rubocop_args, "--", *cask_paths)
|
||||
raise CaskError, "style check failed" unless $CHILD_STATUS.success?
|
||||
true
|
||||
end
|
||||
|
@ -73,7 +73,11 @@ module Homebrew
|
||||
args = %w[
|
||||
--force-exclusion
|
||||
]
|
||||
args << "--auto-correct" if fix
|
||||
if fix
|
||||
args << "--auto-correct"
|
||||
else
|
||||
args << "--parallel"
|
||||
end
|
||||
|
||||
if options[:except_cops]
|
||||
options[:except_cops].map! { |cop| RuboCop::Cop::Cop.registry.qualified_cop_name(cop.to_s, "") }
|
||||
@ -101,14 +105,16 @@ module Homebrew
|
||||
args += files
|
||||
end
|
||||
|
||||
cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" }
|
||||
|
||||
case output_type
|
||||
when :print
|
||||
args << "--display-cop-names" if ARGV.include? "--display-cop-names"
|
||||
args << "--format" << "simple" if files
|
||||
system({ "XDG_CACHE_HOME" => HOMEBREW_CACHE }, "rubocop", *args)
|
||||
system(cache_env, "rubocop", *args)
|
||||
!$?.success?
|
||||
when :json
|
||||
json, _, status = Open3.capture3({ "XDG_CACHE_HOME" => HOMEBREW_CACHE }, "rubocop", "--format", "json", *args)
|
||||
json, _, status = Open3.capture3(cache_env, "rubocop", "--format", "json", *args)
|
||||
# exit status of 1 just means violations were found; other numbers mean
|
||||
# execution errors.
|
||||
# exitstatus can also be nil if RuboCop process crashes, e.g. due to
|
||||
|
@ -1,3 +1,3 @@
|
||||
# RuboCop version used for `brew style` and `brew cask style`
|
||||
HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze
|
||||
HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.12.0".freeze # has to be updated when RuboCop version changes
|
||||
HOMEBREW_RUBOCOP_VERSION = "0.49.1".freeze
|
||||
HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.13.0".freeze # has to be updated when RuboCop version changes
|
||||
|
@ -91,12 +91,12 @@ module Homebrew
|
||||
end
|
||||
|
||||
args = ["-I", HOMEBREW_LIBRARY_PATH/"test"]
|
||||
args += %w[
|
||||
args += %W[
|
||||
--color
|
||||
--require spec_helper
|
||||
--format progress
|
||||
--format ParallelTests::RSpec::RuntimeLogger
|
||||
--out tmp/parallel_runtime_rspec.log
|
||||
--out #{HOMEBREW_CACHE}/tests/parallel_runtime_rspec.log
|
||||
]
|
||||
|
||||
args << "--seed" << ARGV.next if ARGV.include? "--seed"
|
||||
|
@ -2,6 +2,7 @@ class String
|
||||
def undent
|
||||
gsub(/^[ \t]{#{(slice(/^[ \t]+/) || '').length}}/, "")
|
||||
end
|
||||
alias unindent undent
|
||||
|
||||
# eg:
|
||||
# if foo then <<-EOS.undent_________________________________________________________72
|
||||
|
@ -36,7 +36,8 @@ GEM
|
||||
rspec-support (3.6.0)
|
||||
rspec-wait (0.0.9)
|
||||
rspec (>= 3, < 4)
|
||||
rubocop (0.48.1)
|
||||
rubocop (0.49.1)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.3.3.1, < 3.0)
|
||||
powerpack (~> 0.1)
|
||||
rainbow (>= 1.99.1, < 3.0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user