Skip to content
Snippets Groups Projects
Commit 744e7dd1 authored by Mike McQuaid's avatar Mike McQuaid Committed by GitHub
Browse files

Merge pull request #2679 from MikeMcQuaid/parallel-rubocop

Use parallel RuboCop
parents 3165fd25 7a38bab3
No related branches found
No related tags found
No related merge requests found
Showing
with 107 additions and 96 deletions
...@@ -2,9 +2,9 @@ language: ruby ...@@ -2,9 +2,9 @@ language: ruby
cache: cache:
directories: directories:
- $HOME/.gem/ruby - $HOME/.gem/ruby
- $HOME/Library/Caches/Homebrew/style
- $HOME/Library/Caches/Homebrew/tests
- Library/Homebrew/vendor/bundle - Library/Homebrew/vendor/bundle
# For parallel_rspec
- Library/Homebrew/tmp
matrix: matrix:
include: include:
......
...@@ -23,70 +23,94 @@ FormulaAuditStrict/ComponentsRedundancy: ...@@ -23,70 +23,94 @@ FormulaAuditStrict/ComponentsRedundancy:
FormulaAudit/Homepage: FormulaAudit/Homepage:
Enabled: true Enabled: true
Metrics/AbcSize: # `system` is a special case and aligns on second argument
Enabled: false Layout/AlignParameters:
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false Enabled: false
Metrics/CyclomaticComplexity: Layout/CaseIndentation:
Enabled: false EnforcedStyle: end
Metrics/LineLength: Layout/EmptyLineBetweenDefs:
Enabled: false AllowAdjacentOneLineDefs: true
Metrics/MethodLength: Layout/IndentArray:
Enabled: false EnforcedStyle: special_inside_parentheses
Metrics/ModuleLength: Layout/IndentHeredoc:
CountComments: false EnforcedStyle: unindent
Exclude:
- '**/bin/**/*'
- '**/cmd/**/*'
- '**/lib/**/*'
- '**/spec/**/*'
Metrics/PerceivedComplexity: # conflicts with DSL-style path concatenation with `/`
Layout/SpaceAroundOperators:
Enabled: false Enabled: false
# favor parens-less DSL-style arguments # favor parens-less DSL-style arguments
Lint/AmbiguousOperator: Lint/AmbiguousOperator:
Enabled: false Enabled: false
# so many of these in formulae and can't be autocorrected
Lint/AmbiguousRegexpLiteral: Lint/AmbiguousRegexpLiteral:
Enabled: false Enabled: false
# favor parens-less DSL-style arguments
Lint/AmbiguousBlockAssociation:
Enabled: false
# assignment in conditions are useful sometimes
Lint/AssignmentInCondition: Lint/AssignmentInCondition:
Enabled: false Enabled: false
Lint/EndAlignment: Lint/EndAlignment:
EnforcedStyleAlignWith: variable EnforcedStyleAlignWith: variable
# so many of these in formulae and can't be autocorrected
Lint/ParenthesesAsGroupedExpression: Lint/ParenthesesAsGroupedExpression:
Enabled: false Enabled: false
Style/Alias: # TODO: try to bring down all metrics maximums
EnforcedStyle: prefer_alias Metrics/AbcSize:
Max: 250
Style/AlignHash: Metrics/BlockLength:
Enabled: false Max: 1250
# `system` is a special case and aligns on second argument Metrics/ClassLength:
Style/AlignParameters: 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 Enabled: false
Style/Alias:
EnforcedStyle: prefer_alias
Style/AutoResourceCleanup:
Enabled: true
Style/BarePercentLiterals: Style/BarePercentLiterals:
EnforcedStyle: percent_q EnforcedStyle: percent_q
Style/BlockDelimiters: Style/BlockDelimiters:
EnforcedStyle: line_count_based EnforcedStyle: line_count_based
Style/CaseIndentation:
EnforcedStyle: end
Style/ClassAndModuleChildren: Style/ClassAndModuleChildren:
EnforcedStyle: nested EnforcedStyle: nested
...@@ -99,16 +123,22 @@ Style/CommandLiteral: ...@@ -99,16 +123,22 @@ Style/CommandLiteral:
Style/ConditionalAssignment: Style/ConditionalAssignment:
Enabled: false Enabled: false
# most of our APIs are internal so don't require docs
Style/Documentation: Style/Documentation:
Enabled: false Enabled: false
Style/EmptyLineBetweenDefs: Style/Encoding:
AllowAdjacentOneLineDefs: true Enabled: true
# dashes in filenames are typical # dashes in filenames are typical
Style/FileName: Style/FileName:
Regex: !ruby/regexp /^[\w\@\-\+\.]+(\.rb)?$/ 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: Style/GuardClause:
Enabled: false Enabled: false
...@@ -121,13 +151,6 @@ Style/HashSyntax: ...@@ -121,13 +151,6 @@ Style/HashSyntax:
- '**/lib/**/*' - '**/lib/**/*'
- '**/spec/**/*' - '**/spec/**/*'
# disabled until it respects line length
Style/IfUnlessModifier:
Enabled: false
Style/IndentArray:
EnforcedStyle: special_inside_parentheses
# only for numbers >= 1_000_000 # only for numbers >= 1_000_000
Style/NumericLiterals: Style/NumericLiterals:
MinDigits: 7 MinDigits: 7
...@@ -160,13 +183,6 @@ Style/RaiseArgs: ...@@ -160,13 +183,6 @@ Style/RaiseArgs:
Style/RegexpLiteral: Style/RegexpLiteral:
EnforcedStyle: slashes EnforcedStyle: slashes
# conflicts with DSL-style path concatenation with `/`
Style/SpaceAroundOperators:
Enabled: false
Style/SingleLineBlockParams:
Enabled: false
# not a problem for typical shell users # not a problem for typical shell users
Style/SpecialGlobalVars: Style/SpecialGlobalVars:
Enabled: false Enabled: false
...@@ -179,17 +195,22 @@ Style/StringLiterals: ...@@ -179,17 +195,22 @@ Style/StringLiterals:
Style/StringLiteralsInInterpolation: Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes EnforcedStyle: double_quotes
Style/SymbolArray:
EnforcedStyle: brackets
Style/TernaryParentheses: Style/TernaryParentheses:
Enabled: false EnforcedStyle: require_parentheses_when_complex
# makes diffs nicer # makes diffs nicer
Style/TrailingCommaInLiteral: Style/TrailingCommaInLiteral:
EnforcedStyleForMultiline: comma EnforcedStyleForMultiline: comma
Style/TrailingCommaInArguments: Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma EnforcedStyleForMultiline: comma
# we have too many variables like sha256 where this harms readability
Style/VariableNumber: Style/VariableNumber:
Enabled: false Enabled: false
Style/WordArray: Style/WordArray:
Enabled: false MinSize: 4
...@@ -9,9 +9,8 @@ AllCops: ...@@ -9,9 +9,8 @@ AllCops:
- '**/Casks/**/*' - '**/Casks/**/*'
- '**/vendor/**/*' - '**/vendor/**/*'
Style/BlockDelimiters: Layout/MultilineMethodCallIndentation:
Exclude: Exclude:
- '**/cask/spec/**/*'
- '**/*_spec.rb' - '**/*_spec.rb'
# so many of these in formulae but none in here # so many of these in formulae but none in here
...@@ -27,16 +26,13 @@ Lint/NestedMethodDefinition: ...@@ -27,16 +26,13 @@ Lint/NestedMethodDefinition:
Lint/ParenthesesAsGroupedExpression: Lint/ParenthesesAsGroupedExpression:
Enabled: true Enabled: true
Metrics/ModuleLength:
CountComments: false
Exclude:
- 'cask/lib/hbc/locations.rb'
- 'cask/lib/hbc/macos.rb'
- 'cask/lib/hbc/utils.rb'
Metrics/ParameterLists: Metrics/ParameterLists:
CountKeywordArgs: false CountKeywordArgs: false
Style/BlockDelimiters:
Exclude:
- '**/*_spec.rb'
# so many of these in formulae but none in here # so many of these in formulae but none in here
Style/GuardClause: Style/GuardClause:
Enabled: true Enabled: true
......
...@@ -116,7 +116,6 @@ begin ...@@ -116,7 +116,6 @@ begin
odie "Unknown command: #{cmd}" odie "Unknown command: #{cmd}"
end end
end end
rescue UsageError => e rescue UsageError => e
require "cmd/help" require "cmd/help"
Homebrew.help cmd, usage_error: e.message Homebrew.help cmd, usage_error: e.message
......
...@@ -10,7 +10,7 @@ module Hbc ...@@ -10,7 +10,7 @@ module Hbc
end end
def self.artifact_english_article def self.artifact_english_article
@artifact_english_article ||= artifact_english_name =~ /^[aeiou]/i ? "an" : "a" @artifact_english_article ||= (artifact_english_name =~ /^[aeiou]/i) ? "an" : "a"
end end
def self.artifact_dsl_key def self.artifact_dsl_key
...@@ -43,7 +43,7 @@ module Hbc ...@@ -43,7 +43,7 @@ module Hbc
unless unknown_keys.empty? unless unknown_keys.empty?
opoo %Q{Unknown arguments to #{description} -- #{unknown_keys.inspect} (ignored). Running "brew update; brew cleanup; brew cask cleanup" will likely fix it.} opoo %Q{Unknown arguments to #{description} -- #{unknown_keys.inspect} (ignored). Running "brew update; brew cleanup; brew cask cleanup" will likely fix it.}
end end
arguments.reject! { |k| !permitted_keys.include?(k) } arguments.select! { |k| permitted_keys.include?(k) }
# key warnings # key warnings
override_keys = override_arguments.keys override_keys = override_arguments.keys
......
...@@ -197,9 +197,7 @@ module Hbc ...@@ -197,9 +197,7 @@ module Hbc
paths.each do |path| paths.each do |path|
resolved_path = Pathname.new(path) resolved_path = Pathname.new(path)
if path.start_with?("~") resolved_path = resolved_path.expand_path if path.start_with?("~")
resolved_path = resolved_path.expand_path
end
if resolved_path.relative? || resolved_path.split.any? { |part| part.to_s == ".." } if resolved_path.relative? || resolved_path.split.any? { |part| part.to_s == ".." }
opoo "Skipping #{Formatter.identifier(action)} for relative path '#{path}'." opoo "Skipping #{Formatter.identifier(action)} for relative path '#{path}'."
......
...@@ -66,7 +66,7 @@ module Hbc ...@@ -66,7 +66,7 @@ module Hbc
return [] if current == version return [] if current == version
# collect all installed versions that are different than tap version and return them # collect all installed versions that are different than tap version and return them
installed.select { |v| v != version } installed.reject { |v| v == version }
end end
def to_s def to_s
......
...@@ -54,7 +54,7 @@ module Hbc ...@@ -54,7 +54,7 @@ module Hbc
class FromURILoader < FromPathLoader class FromURILoader < FromPathLoader
def self.can_load?(ref) def self.can_load?(ref)
!(ref.to_s !~ ::URI.regexp) ref.to_s =~ ::URI.regexp
end end
def initialize(url) def initialize(url)
...@@ -80,7 +80,7 @@ module Hbc ...@@ -80,7 +80,7 @@ module Hbc
class FromTapLoader < FromPathLoader class FromTapLoader < FromPathLoader
def self.can_load?(ref) def self.can_load?(ref)
!(ref.to_s !~ HOMEBREW_TAP_CASK_REGEX) ref.to_s =~ HOMEBREW_TAP_CASK_REGEX
end end
def initialize(tapped_name) def initialize(tapped_name)
......
...@@ -140,9 +140,7 @@ module Hbc ...@@ -140,9 +140,7 @@ module Hbc
command_name, *args = *@args command_name, *args = *@args
command = help? ? "help" : self.class.lookup_command(command_name) command = help? ? "help" : self.class.lookup_command(command_name)
unless ENV["MACOS_VERSION"].nil? MacOS.full_version = ENV["MACOS_VERSION"] unless ENV["MACOS_VERSION"].nil?
MacOS.full_version = ENV["MACOS_VERSION"]
end
Hbc.default_tap.install unless Hbc.default_tap.installed? Hbc.default_tap.install unless Hbc.default_tap.installed?
Hbc.init if self.class.should_init?(command) Hbc.init if self.class.should_init?(command)
......
...@@ -15,7 +15,7 @@ module Hbc ...@@ -15,7 +15,7 @@ module Hbc
end end
def self.abstract? def self.abstract?
!(name.split("::").last !~ /^Abstract[^a-z]/) name.split("::").last =~ /^Abstract[^a-z]/
end end
def self.visible def self.visible
......
...@@ -17,17 +17,17 @@ module Hbc ...@@ -17,17 +17,17 @@ module Hbc
ohai "Contents of $LOAD_PATH", self.class.render_load_path($LOAD_PATH) ohai "Contents of $LOAD_PATH", self.class.render_load_path($LOAD_PATH)
ohai "Environment Variables" ohai "Environment Variables"
environment_variables = [ environment_variables = %w[
"RUBYLIB", RUBYLIB
"RUBYOPT", RUBYOPT
"RUBYPATH", RUBYPATH
"RBENV_VERSION", RBENV_VERSION
"CHRUBY_VERSION", CHRUBY_VERSION
"GEM_HOME", GEM_HOME
"GEM_PATH", GEM_PATH
"BUNDLE_PATH", BUNDLE_PATH
"PATH", PATH
"SHELL", SHELL
] ]
(self.class.locale_variables + environment_variables).sort.each(&self.class.method(:render_env_var)) (self.class.locale_variables + environment_variables).sort.each(&self.class.method(:render_env_var))
......
...@@ -41,7 +41,7 @@ module Hbc ...@@ -41,7 +41,7 @@ module Hbc
puts versioned_staged_path.to_s puts versioned_staged_path.to_s
.concat(" (") .concat(" (")
.concat(versioned_staged_path.exist? ? versioned_staged_path.abv : Formatter.error("does not exist")) .concat(versioned_staged_path.exist? ? versioned_staged_path.abv : Formatter.error("does not exist"))
.concat(")") .concat(")")
end end
else else
puts "Not installed" puts "Not installed"
...@@ -49,7 +49,7 @@ module Hbc ...@@ -49,7 +49,7 @@ module Hbc
end end
def self.name_info(cask) def self.name_info(cask)
ohai cask.name.size > 1 ? "Names" : "Name" ohai((cask.name.size > 1) ? "Names" : "Name")
puts cask.name.empty? ? Formatter.error("None") : cask.name puts cask.name.empty? ? Formatter.error("None") : cask.name
end end
...@@ -69,7 +69,7 @@ module Hbc ...@@ -69,7 +69,7 @@ module Hbc
DSL::ORDINARY_ARTIFACT_TYPES.each do |type| DSL::ORDINARY_ARTIFACT_TYPES.each do |type|
next if cask.artifacts[type].empty? next if cask.artifacts[type].empty?
cask.artifacts[type].each do |artifact| cask.artifacts[type].each do |artifact|
activatable_item = type == :stage_only ? "<none>" : artifact.first activatable_item = (type == :stage_only) ? "<none>" : artifact.first
puts "#{activatable_item} (#{type})" puts "#{activatable_item} (#{type})"
end end
end end
......
...@@ -24,7 +24,7 @@ module Hbc ...@@ -24,7 +24,7 @@ module Hbc
begin begin
cask = CaskLoader.load(cask_token) cask = CaskLoader.load(cask_token)
Installer.new(cask, binaries: binaries?, Installer.new(cask, binaries: binaries?,
verbose: verbose?, verbose: verbose?,
force: force?, force: force?,
skip_cask_deps: skip_cask_deps?, skip_cask_deps: skip_cask_deps?,
require_sha: require_sha?).install require_sha: require_sha?).install
......
...@@ -43,7 +43,7 @@ module Hbc ...@@ -43,7 +43,7 @@ module Hbc
if checkpoint.nil? if checkpoint.nil?
onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}" onoe "Could not retrieve `appcast` checkpoint for cask '#{cask}': #{result[:command_result].stderr}"
else else
puts cask_tokens.count > 1 ? "#{checkpoint} #{cask}": checkpoint puts((cask_tokens.count > 1) ? "#{checkpoint} #{cask}": checkpoint)
count += 1 count += 1
end end
end end
......
...@@ -12,7 +12,7 @@ module Hbc ...@@ -12,7 +12,7 @@ module Hbc
def run def run
retval = args.any? ? list : list_installed retval = args.any? ? list : list_installed
# retval is ternary: true/false/nil # retval is ternary: true/false/nil
if retval.nil? && !args.any? if retval.nil? && args.none?
opoo "nothing to list" # special case: avoid exit code opoo "nothing to list" # special case: avoid exit code
elsif retval.nil? elsif retval.nil?
raise CaskError, "nothing to list" raise CaskError, "nothing to list"
......
...@@ -11,7 +11,8 @@ module Hbc ...@@ -11,7 +11,8 @@ module Hbc
def run def run
install_rubocop 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? raise CaskError, "style check failed" unless $CHILD_STATUS.success?
true true
end end
......
...@@ -86,7 +86,7 @@ module Hbc ...@@ -86,7 +86,7 @@ module Hbc
Dir.chdir(mount) do Dir.chdir(mount) do
Dir.glob("**/*", File::FNM_DOTMATCH).map do |path| Dir.glob("**/*", File::FNM_DOTMATCH).map do |path|
next if skip_path?(Pathname(path)) next if skip_path?(Pathname(path))
path == "." ? path : path.prepend("./") (path == ".") ? path : path.prepend("./")
end.compact.join("\n").concat("\n") end.compact.join("\n").concat("\n")
end end
end end
......
...@@ -212,7 +212,7 @@ module Hbc ...@@ -212,7 +212,7 @@ module Hbc
class SubversionDownloadStrategy < HbVCSDownloadStrategy class SubversionDownloadStrategy < HbVCSDownloadStrategy
def cache_tag def cache_tag
# TODO: pass versions as symbols, support :head here # TODO: pass versions as symbols, support :head here
version == "head" ? "svn-HEAD" : "svn" (version == "head") ? "svn-HEAD" : "svn"
end end
def repo_valid? def repo_valid?
......
...@@ -119,9 +119,7 @@ module Hbc ...@@ -119,9 +119,7 @@ module Hbc
def language_eval def language_eval
return @language if instance_variable_defined?(:@language) return @language if instance_variable_defined?(:@language)
if @language_blocks.nil? || @language_blocks.empty? return @language = nil if @language_blocks.nil? || @language_blocks.empty?
return @language = nil
end
MacOS.languages.map(&Locale.method(:parse)).each do |locale| MacOS.languages.map(&Locale.method(:parse)).each do |locale|
key = @language_blocks.keys.detect do |strings| key = @language_blocks.keys.detect do |strings|
......
...@@ -113,7 +113,7 @@ module Hbc ...@@ -113,7 +113,7 @@ module Hbc
end end
def to_s def to_s
"Cask '#{token}' definition is invalid" + (!submsg.empty? ? ": #{submsg}" : "") "Cask '#{token}' definition is invalid#{": #{submsg}" unless submsg.empty?}"
end end
end end
......
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