Skip to content
Snippets Groups Projects
Commit 4356016b authored by Mike McQuaid's avatar Mike McQuaid
Browse files

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.
parent 3165fd25
No related branches found
No related tags found
No related merge requests found
......@@ -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,70 +23,94 @@ FormulaAuditStrict/ComponentsRedundancy:
FormulaAudit/Homepage:
Enabled: true
Metrics/AbcSize:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
# `system` is a special case and aligns on second argument
Layout/AlignParameters:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Layout/CaseIndentation:
EnforcedStyle: end
Metrics/LineLength:
Enabled: false
Layout/EmptyLineBetweenDefs:
AllowAdjacentOneLineDefs: true
Metrics/MethodLength:
Enabled: false
Layout/IndentArray:
EnforcedStyle: special_inside_parentheses
Metrics/ModuleLength:
CountComments: false
Exclude:
- '**/bin/**/*'
- '**/cmd/**/*'
- '**/lib/**/*'
- '**/spec/**/*'
Layout/IndentHeredoc:
EnforcedStyle: unindent
Metrics/PerceivedComplexity:
# 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
Style/Alias:
EnforcedStyle: prefer_alias
# TODO: try to bring down all metrics maximums
Metrics/AbcSize:
Max: 250
Style/AlignHash:
Enabled: false
Metrics/BlockLength:
Max: 1250
# `system` is a special case and aligns on second argument
Style/AlignParameters:
Metrics/ClassLength:
Max: 1500
Metrics/CyclomaticComplexity:
Max: 75
Metrics/LineLength:
Max: 400
Metrics/MethodLength:
Max: 250
Metrics/ModuleLength:
CountComments: false
Exclude:
- '**/bin/**/*'
- '**/cmd/**/*'
- '**/lib/**/*'
Metrics/PerceivedComplexity:
Max: 80
# makes code less readable for minor performance increases
Performance/Caller:
Enabled: false
Style/Alias:
EnforcedStyle: prefer_alias
Style/AutoResourceCleanup:
Enabled: true
Style/BarePercentLiterals:
EnforcedStyle: percent_q
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
......
# 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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment