Merge pull request #2679 from MikeMcQuaid/parallel-rubocop

Use parallel RuboCop
This commit is contained in:
Mike McQuaid 2017-05-29 19:22:46 +01:00 committed by GitHub
commit 744e7dd190
53 changed files with 194 additions and 187 deletions

View File

@ -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:

View File

@ -23,23 +23,67 @@ FormulaAuditStrict/ComponentsRedundancy:
FormulaAudit/Homepage: FormulaAudit/Homepage:
Enabled: true Enabled: true
Metrics/AbcSize: # `system` is a special case and aligns on second argument
Layout/AlignParameters:
Enabled: false 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: Metrics/BlockLength:
Enabled: false Max: 1250
Metrics/ClassLength: Metrics/ClassLength:
Enabled: false Max: 1500
Metrics/CyclomaticComplexity: Metrics/CyclomaticComplexity:
Enabled: false Max: 75
Metrics/LineLength: Metrics/LineLength:
Enabled: false Max: 400
Metrics/MethodLength: Metrics/MethodLength:
Enabled: false Max: 250
Metrics/ModuleLength: Metrics/ModuleLength:
CountComments: false CountComments: false
@ -47,36 +91,19 @@ Metrics/ModuleLength:
- '**/bin/**/*' - '**/bin/**/*'
- '**/cmd/**/*' - '**/cmd/**/*'
- '**/lib/**/*' - '**/lib/**/*'
- '**/spec/**/*'
Metrics/PerceivedComplexity: Metrics/PerceivedComplexity:
Enabled: false Max: 80
# favor parens-less DSL-style arguments # makes code less readable for minor performance increases
Lint/AmbiguousOperator: Performance/Caller:
Enabled: false
Lint/AmbiguousRegexpLiteral:
Enabled: false
Lint/AssignmentInCondition:
Enabled: false
Lint/EndAlignment:
EnforcedStyleAlignWith: variable
Lint/ParenthesesAsGroupedExpression:
Enabled: false Enabled: false
Style/Alias: Style/Alias:
EnforcedStyle: prefer_alias EnforcedStyle: prefer_alias
Style/AlignHash: Style/AutoResourceCleanup:
Enabled: false Enabled: true
# `system` is a special case and aligns on second argument
Style/AlignParameters:
Enabled: false
Style/BarePercentLiterals: Style/BarePercentLiterals:
EnforcedStyle: percent_q EnforcedStyle: percent_q
@ -84,9 +111,6 @@ Style/BarePercentLiterals:
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:
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:
- '**/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:
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:
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

View File

@ -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:
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

View File

@ -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

View File

@ -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
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

View File

@ -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}'."

View File

@ -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

View File

@ -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
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)

View File

@ -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)

View File

@ -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

View File

@ -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))

View File

@ -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
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
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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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?

View File

@ -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|

View File

@ -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

View File

@ -94,7 +94,7 @@ module Hbc
loop do loop do
readable_sources = IO.select(sources)[0] readable_sources = IO.select(sources)[0]
readable_sources.delete_if(&:eof?).first(1).each do |source| readable_sources.delete_if(&:eof?).first(1).each do |source|
type = (source == sources[0] ? :stdout : :stderr) type = ((source == sources[0]) ? :stdout : :stderr)
begin begin
yield(type, source.readline_nonblock || "") yield(type, source.readline_nonblock || "")
rescue IO::WaitReadable, EOFError rescue IO::WaitReadable, EOFError

View File

@ -38,6 +38,7 @@
#: `--include-optional`, and `--skip-recommended` as documented above. #: `--include-optional`, and `--skip-recommended` as documented above.
# encoding: UTF-8 # encoding: UTF-8
require "formula" require "formula"
require "ostruct" require "ostruct"
@ -112,10 +113,10 @@ module Homebrew
end end
else else
deps = f.deps.reject do |dep| deps = f.deps.reject do |dep|
ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } ignores.any? { |ignore| dep.send(ignore) } && includes.none? { |include| dep.send(include) }
end end
reqs = f.requirements.reject do |req| reqs = f.requirements.reject do |req|
ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } ignores.any? { |ignore| req.send(ignore) } && includes.none? { |include| req.send(include) }
end end
end end
@ -160,7 +161,7 @@ module Homebrew
else else
"├──" "├──"
end end
prefix_ext = i == max ? " " : "" prefix_ext = (i == max) ? " " : ""
puts prefix + "#{chr} #{dep_display_name(dep)}" puts prefix + "#{chr} #{dep_display_name(dep)}"
recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_ext) recursive_deps_tree(Formulary.factory(dep.name), prefix + prefix_ext)
end end

View File

@ -1,27 +1,27 @@
HOMEBREW_HELP = <<-EOS.freeze HOMEBREW_HELP = <<-EOS.unindent.freeze
Example usage: Example usage:
brew search [TEXT|/REGEX/] brew search [TEXT|/REGEX/]
brew (info|home|options) [FORMULA...] brew (info|home|options) [FORMULA...]
brew install FORMULA... brew install FORMULA...
brew update brew update
brew upgrade [FORMULA...] brew upgrade [FORMULA...]
brew uninstall FORMULA... brew uninstall FORMULA...
brew list [FORMULA...] brew list [FORMULA...]
Troubleshooting: Troubleshooting:
brew config brew config
brew doctor brew doctor
brew install -vd FORMULA brew install -vd FORMULA
Developers: Developers:
brew create [URL [--no-fetch]] brew create [URL [--no-fetch]]
brew edit [FORMULA...] brew edit [FORMULA...]
http://docs.brew.sh/Formula-Cookbook.html http://docs.brew.sh/Formula-Cookbook.html
Further help: Further help:
man brew man brew
brew help [COMMAND] brew help [COMMAND]
brew home brew home
EOS EOS
# NOTE Keep the lenth of vanilla --help less than 25 lines! # NOTE Keep the lenth of vanilla --help less than 25 lines!

View File

@ -72,9 +72,7 @@ module Homebrew
puts "#{n} symlinks created" puts "#{n} symlinks created"
end end
if keg_only && !ARGV.homebrew_developer? puts_keg_only_path_message(keg) if keg_only && !ARGV.homebrew_developer?
puts_keg_only_path_message(keg)
end
end end
end end
end end

View File

@ -73,7 +73,11 @@ module Homebrew
args = %w[ args = %w[
--force-exclusion --force-exclusion
] ]
args << "--auto-correct" if fix if fix
args << "--auto-correct"
else
args << "--parallel"
end
if options[:except_cops] if options[:except_cops]
options[:except_cops].map! { |cop| RuboCop::Cop::Cop.registry.qualified_cop_name(cop.to_s, "") } options[:except_cops].map! { |cop| RuboCop::Cop::Cop.registry.qualified_cop_name(cop.to_s, "") }
@ -101,14 +105,16 @@ module Homebrew
args += files args += files
end end
cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" }
case output_type case output_type
when :print when :print
args << "--display-cop-names" if ARGV.include? "--display-cop-names" args << "--display-cop-names" if ARGV.include? "--display-cop-names"
args << "--format" << "simple" if files args << "--format" << "simple" if files
system({ "XDG_CACHE_HOME" => HOMEBREW_CACHE }, "rubocop", *args) system(cache_env, "rubocop", *args)
!$?.success? !$?.success?
when :json 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 # exit status of 1 just means violations were found; other numbers mean
# execution errors. # execution errors.
# exitstatus can also be nil if RuboCop process crashes, e.g. due to # exitstatus can also be nil if RuboCop process crashes, e.g. due to

View File

@ -98,10 +98,10 @@ module Homebrew
reqs = reqs_by_formula.map(&:last) reqs = reqs_by_formula.map(&:last)
else else
deps = f.deps.reject do |dep| deps = f.deps.reject do |dep|
ignores.any? { |ignore| dep.send(ignore) } && !includes.any? { |include| dep.send(include) } ignores.any? { |ignore| dep.send(ignore) } && includes.none? { |include| dep.send(include) }
end end
reqs = f.requirements.reject do |req| reqs = f.requirements.reject do |req|
ignores.any? { |ignore| req.send(ignore) } && !includes.any? { |include| req.send(include) } ignores.any? { |ignore| req.send(ignore) } && includes.none? { |include| req.send(include) }
end end
end end
next true if deps.any? do |dep| next true if deps.any? do |dep|

View File

@ -19,5 +19,5 @@ end
def plural(n, s = "s") def plural(n, s = "s")
odeprecated "#plural", "Formatter.pluralize" odeprecated "#plural", "Formatter.pluralize"
n == 1 ? "" : s (n == 1) ? "" : s
end end

View File

@ -1,3 +1,3 @@
# RuboCop version used for `brew style` and `brew cask style` # RuboCop version used for `brew style` and `brew cask style`
HOMEBREW_RUBOCOP_VERSION = "0.47.1".freeze HOMEBREW_RUBOCOP_VERSION = "0.49.1".freeze
HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.12.0".freeze # has to be updated when RuboCop version changes HOMEBREW_RUBOCOP_CASK_VERSION = "~> 0.13.0".freeze # has to be updated when RuboCop version changes

View File

@ -16,7 +16,7 @@ class CxxStdlib
if type && ![:libstdcxx, :libcxx].include?(type) if type && ![:libstdcxx, :libcxx].include?(type)
raise ArgumentError, "Invalid C++ stdlib type: #{type}" raise ArgumentError, "Invalid C++ stdlib type: #{type}"
end end
klass = compiler.to_s =~ GNU_GCC_REGEXP ? GnuStdlib : AppleStdlib klass = (compiler.to_s =~ GNU_GCC_REGEXP) ? GnuStdlib : AppleStdlib
klass.new(type, compiler) klass.new(type, compiler)
end end

View File

@ -121,7 +121,7 @@ class Descriptions
blank = Formatter.warning("[no description]") blank = Formatter.warning("[no description]")
@descriptions.keys.sort.each do |full_name| @descriptions.keys.sort.each do |full_name|
short_name = short_names[full_name] short_name = short_names[full_name]
printed_name = short_name_counts[short_name] == 1 ? short_name : full_name printed_name = (short_name_counts[short_name] == 1) ? short_name : full_name
description = @descriptions[full_name] || blank description = @descriptions[full_name] || blank
puts "#{Tty.bold}#{printed_name}:#{Tty.reset} #{description}" puts "#{Tty.bold}#{printed_name}:#{Tty.reset} #{description}"
end end

View File

@ -591,9 +591,7 @@ class FormulaAuditor
def audit_homepage def audit_homepage
homepage = formula.homepage homepage = formula.homepage
if homepage.nil? || homepage.empty? return if homepage.nil? || homepage.empty?
return
end
return unless @online return unless @online
@ -988,9 +986,7 @@ class FormulaAuditor
problem ":apr is deprecated. Usage should be \"apr-util\"" problem ":apr is deprecated. Usage should be \"apr-util\""
end end
if line =~ /depends_on :tex/ problem ":tex is deprecated" if line =~ /depends_on :tex/
problem ":tex is deprecated"
end
if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+:(lua|perl|python|ruby)(\d*)/ if line =~ /depends_on\s+['"](.+)['"]\s+=>\s+:(lua|perl|python|ruby)(\d*)/
problem "#{$2} modules should be vendored rather than use deprecated `depends_on \"#{$1}\" => :#{$2}#{$3}`" problem "#{$2} modules should be vendored rather than use deprecated `depends_on \"#{$1}\" => :#{$2}#{$3}`"

View File

@ -314,8 +314,8 @@ module Homebrew
old_spec = f.bottle_specification old_spec = f.bottle_specification
if ARGV.include?("--keep-old") && !old_spec.checksums.empty? if ARGV.include?("--keep-old") && !old_spec.checksums.empty?
mismatches = [:root_url, :prefix, :cellar, :rebuild].select do |key| mismatches = [:root_url, :prefix, :cellar, :rebuild].reject do |key|
old_spec.send(key) != bottle.send(key) old_spec.send(key) == bottle.send(key)
end end
mismatches.delete(:cellar) if old_spec.cellar == :any && bottle.cellar == :any_skip_relocation mismatches.delete(:cellar) if old_spec.cellar == :any && bottle.cellar == :any_skip_relocation
unless mismatches.empty? unless mismatches.empty?
@ -382,9 +382,7 @@ module Homebrew
bottle = BottleSpecification.new bottle = BottleSpecification.new
bottle.root_url bottle_hash["bottle"]["root_url"] bottle.root_url bottle_hash["bottle"]["root_url"]
cellar = bottle_hash["bottle"]["cellar"] cellar = bottle_hash["bottle"]["cellar"]
if cellar == "any" || cellar == "any_skip_relocation" cellar = cellar.to_sym if ["any", "any_skip_relocation"].include?(cellar)
cellar = cellar.to_sym
end
bottle.cellar cellar bottle.cellar cellar
bottle.prefix bottle_hash["bottle"]["prefix"] bottle.prefix bottle_hash["bottle"]["prefix"]
bottle.rebuild bottle_hash["bottle"]["rebuild"] bottle.rebuild bottle_hash["bottle"]["rebuild"]

View File

@ -21,7 +21,7 @@ module Homebrew
# If no brews are listed, open the project root in an editor. # If no brews are listed, open the project root in an editor.
if ARGV.named.empty? if ARGV.named.empty?
editor = File.basename which_editor editor = File.basename which_editor
if editor == "mate" || editor == "subl" if ["mate", "subl"].include?(editor)
# If the user is using TextMate or Sublime Text, # If the user is using TextMate or Sublime Text,
# give a nice project view instead. # give a nice project view instead.
exec_editor HOMEBREW_REPOSITORY+"bin/brew", exec_editor HOMEBREW_REPOSITORY+"bin/brew",

View File

@ -60,9 +60,7 @@ module Homebrew
end end
Homebrew.install_gem_setup_path! "bundler" Homebrew.install_gem_setup_path! "bundler"
unless quiet_system("bundle", "check") system "bundle", "install" unless quiet_system("bundle", "check")
system "bundle", "install"
end
parallel = true parallel = true
@ -91,12 +89,12 @@ module Homebrew
end end
args = ["-I", HOMEBREW_LIBRARY_PATH/"test"] args = ["-I", HOMEBREW_LIBRARY_PATH/"test"]
args += %w[ args += %W[
--color --color
--require spec_helper --require spec_helper
--format progress --format progress
--format ParallelTests::RSpec::RuntimeLogger --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" args << "--seed" << ARGV.next if ARGV.include? "--seed"

View File

@ -2,6 +2,7 @@ class String
def undent def undent
gsub(/^[ \t]{#{(slice(/^[ \t]+/) || '').length}}/, "") gsub(/^[ \t]{#{(slice(/^[ \t]+/) || '').length}}/, "")
end end
alias unindent undent
# eg: # eg:
# if foo then <<-EOS.undent_________________________________________________________72 # if foo then <<-EOS.undent_________________________________________________________72

View File

@ -61,9 +61,9 @@ module FormulaCellarChecks
valid_extensions = %w[.a .dylib .framework .jnilib .la .o .so valid_extensions = %w[.a .dylib .framework .jnilib .la .o .so
.jar .prl .pm .sh] .jar .prl .pm .sh]
non_libraries = formula.lib.children.select do |g| non_libraries = formula.lib.children.reject do |g|
next if g.directory? next if g.directory?
!valid_extensions.include? g.extname valid_extensions.include? g.extname
end end
return if non_libraries.empty? return if non_libraries.empty?

View File

@ -472,7 +472,7 @@ class FormulaInstaller
def effective_build_options_for(dependent, inherited_options = []) def effective_build_options_for(dependent, inherited_options = [])
args = dependent.build.used_options args = dependent.build.used_options
args |= dependent == formula ? options : inherited_options args |= (dependent == formula) ? options : inherited_options
args |= Tab.for_formula(dependent).used_options args |= Tab.for_formula(dependent).used_options
args &= dependent.options args &= dependent.options
BuildOptions.new(args, dependent.options) BuildOptions.new(args, dependent.options)
@ -680,7 +680,6 @@ class FormulaInstaller
if !formula.prefix.directory? || Keg.new(formula.prefix).empty_installation? if !formula.prefix.directory? || Keg.new(formula.prefix).empty_installation?
raise "Empty installation" raise "Empty installation"
end end
rescue Exception rescue Exception
ignore_interrupts do ignore_interrupts do
# any exceptions must leave us with nothing installed # any exceptions must leave us with nothing installed

View File

@ -367,7 +367,7 @@ class Keg
dep_formula = Formulary.factory(dep["full_name"]) dep_formula = Formulary.factory(dep["full_name"])
dep_formula == to_formula dep_formula == to_formula
rescue FormulaUnavailableError rescue FormulaUnavailableError
next "#{tap}/#{name}" == dep["full_name"] next dep["full_name"] == "#{tap}/#{name}"
end end
end end
end end

View File

@ -47,7 +47,7 @@ module Language
def cabal_install(*args) def cabal_install(*args)
# cabal hardcodes 64 as the maximum number of parallel jobs # cabal hardcodes 64 as the maximum number of parallel jobs
# https://github.com/Homebrew/legacy-homebrew/issues/49509 # https://github.com/Homebrew/legacy-homebrew/issues/49509
make_jobs = ENV.make_jobs > 64 ? 64 : ENV.make_jobs make_jobs = (ENV.make_jobs > 64) ? 64 : ENV.make_jobs
# cabal-install's dependency-resolution backtracking strategy can easily # cabal-install's dependency-resolution backtracking strategy can easily
# need more than the default 2,000 maximum number of "backjumps," since # need more than the default 2,000 maximum number of "backjumps," since

View File

@ -90,7 +90,7 @@ module OS
@locator ||= SDKLocator.new @locator ||= SDKLocator.new
begin begin
sdk = if v.nil? sdk = if v.nil?
Xcode.version.to_i >= 7 ? @locator.latest_sdk : @locator.sdk_for(version) (Xcode.version.to_i >= 7) ? @locator.latest_sdk : @locator.sdk_for(version)
else else
@locator.sdk_for v @locator.sdk_for v
end end

View File

@ -62,10 +62,10 @@ class LinkageChecker
declared_deps = formula.deps.reject { |dep| filter_out.call(dep) }.map(&:name) declared_deps = formula.deps.reject { |dep| filter_out.call(dep) }.map(&:name)
declared_requirement_deps = formula.requirements.reject { |req| filter_out.call(req) }.map(&:default_formula).compact declared_requirement_deps = formula.requirements.reject { |req| filter_out.call(req) }.map(&:default_formula).compact
declared_dep_names = (declared_deps + declared_requirement_deps).map { |dep| dep.split("/").last } declared_dep_names = (declared_deps + declared_requirement_deps).map { |dep| dep.split("/").last }
undeclared_deps = @brewed_dylibs.keys.select do |full_name| undeclared_deps = @brewed_dylibs.keys.reject do |full_name|
name = full_name.split("/").last name = full_name.split("/").last
next false if name == formula.name next true if name == formula.name
!declared_dep_names.include?(name) declared_dep_names.include?(name)
end end
undeclared_deps.sort do |a, b| undeclared_deps.sort do |a, b|
if a.include?("/") && !b.include?("/") if a.include?("/") && !b.include?("/")

View File

@ -96,7 +96,7 @@ module RuboCop
else else
indentation = " " * (start_column(node2) - line_start_column(node2)) indentation = " " * (start_column(node2) - line_start_column(node2))
# No line breaks upto version_scheme, order_idx == 8 # No line breaks upto version_scheme, order_idx == 8
line_breaks = order_idx>8 ? "\n\n" : "\n" line_breaks = (order_idx>8) ? "\n\n" : "\n"
corrector.insert_before(node2.source_range, node1.source+line_breaks+indentation) corrector.insert_before(node2.source_range, node1.source+line_breaks+indentation)
end end
corrector.remove(range_with_surrounding_space(node1.source_range, :left)) corrector.remove(range_with_surrounding_space(node1.source_range, :left))

View File

@ -176,7 +176,7 @@ class Sandbox
def add_rule(rule) def add_rule(rule)
s = "(" s = "("
s << (rule[:allow] ? "allow": "deny") s << ((rule[:allow]) ? "allow": "deny")
s << " #{rule[:operation]}" s << " #{rule[:operation]}"
s << " (#{rule[:filter]})" if rule[:filter] s << " (#{rule[:filter]})" if rule[:filter]
s << " (with #{rule[:modifier]})" if rule[:modifier] s << " (with #{rule[:modifier]})" if rule[:modifier]

View File

@ -235,7 +235,7 @@ class Bottle
end end
def suffix def suffix
s = rebuild > 0 ? ".#{rebuild}" : "" s = (rebuild > 0) ? ".#{rebuild}" : ""
".bottle#{s}.tar.gz" ".bottle#{s}.tar.gz"
end end
end end

View File

@ -2,11 +2,11 @@ source "https://rubygems.org"
gem "parallel_tests" gem "parallel_tests"
gem "rspec" gem "rspec"
gem "rubocop"
gem "rspec-its", require: false gem "rspec-its", require: false
gem "rspec-wait", require: false gem "rspec-wait", require: false
gem "rubocop"
group :coverage do group :coverage do
gem "simplecov", require: false
gem "codecov", require: false gem "codecov", require: false
gem "simplecov", require: false
end end

View File

@ -36,7 +36,8 @@ GEM
rspec-support (3.6.0) rspec-support (3.6.0)
rspec-wait (0.0.9) rspec-wait (0.0.9)
rspec (>= 3, < 4) rspec (>= 3, < 4)
rubocop (0.48.1) rubocop (0.49.1)
parallel (~> 1.10)
parser (>= 2.3.3.1, < 3.0) parser (>= 2.3.3.1, < 3.0)
powerpack (~> 0.1) powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0) rainbow (>= 1.99.1, < 3.0)

View File

@ -1,6 +1,6 @@
describe "download strategies", :cask do describe "download strategies", :cask do
let(:url) { "http://example.com/cask.dmg" } let(:url) { "http://example.com/cask.dmg" }
let(:url_options) { Hash.new } let(:url_options) { {} }
let(:cask) { let(:cask) {
instance_double(Hbc::Cask, token: "some-cask", instance_double(Hbc::Cask, token: "some-cask",
url: Hbc::URL.new(url, url_options), url: Hbc::URL.new(url, url_options),

View File

@ -4,11 +4,11 @@ require "utils/tty"
describe Formatter do describe Formatter do
describe "::columns" do describe "::columns" do
let(:input) { let(:input) {
[ %w[
"aa", aa
"bbb", bbb
"ccc", ccc
"dd", dd
] ]
} }
subject { described_class.columns(input) } subject { described_class.columns(input) }

View File

@ -683,7 +683,7 @@ describe Formula do
end end
expect(f5.deps.map(&:name)).to eq(["f3", "f4"]) expect(f5.deps.map(&:name)).to eq(["f3", "f4"])
expect(f5.recursive_dependencies.map(&:name)).to eq(["f1", "f2", "f3", "f4"]) expect(f5.recursive_dependencies.map(&:name)).to eq(%w[f1 f2 f3 f4])
expect(f5.runtime_dependencies.map(&:name)).to eq(["f1", "f4"]) expect(f5.runtime_dependencies.map(&:name)).to eq(["f1", "f4"])
end end

View File

@ -44,9 +44,7 @@ describe Migrator do
end end
after(:each) do after(:each) do
if !old_keg_record.parent.symlink? && old_keg_record.directory? keg.unlink if !old_keg_record.parent.symlink? && old_keg_record.directory?
keg.unlink
end
if new_keg_record.directory? if new_keg_record.directory?
new_keg = Keg.new(new_keg_record) new_keg = Keg.new(new_keg_record)

View File

@ -104,7 +104,7 @@ describe Pathname do
end end
it "preserves permissions" do it "preserves permissions" do
File.open(file, "w", 0100777).close File.open(file, "w", 0100777) {}
file.atomic_write("CONTENT") file.atomic_write("CONTENT")
expect(file.stat.mode).to eq(0100777 & ~File.umask) expect(file.stat.mode).to eq(0100777 & ~File.umask)
end end

View File

@ -3,19 +3,19 @@ require "extend/string"
describe String do describe String do
describe "#undent" do describe "#undent" do
it "removes leading whitespace, taking the first line as reference" do it "removes leading whitespace, taking the first line as reference" do
string = <<-EOS.undent string = <<-EOS.unindent
hi hi
........my friend over ........my friend over
there there
EOS EOS
expect(string).to eq("hi\n........my friend over\n there\n") expect(string).to eq("hi\n........my friend over\n there\n")
end end
it "removes nothing if the text is not indented" do it "removes nothing if the text is not indented" do
string = <<-EOS.undent string = <<-EOS.unindent
hi hi
I'm not indented I'm not indented
EOS EOS
expect(string).to eq("hi\nI'm not indented\n") expect(string).to eq("hi\nI'm not indented\n")

View File

@ -280,7 +280,7 @@ class Version
private private
def max(a, b) def max(a, b)
a > b ? a : b (a > b) ? a : b
end end
def tokenize def tokenize