rubocop: apply autofixes.

This commit is contained in:
Mike McQuaid 2020-03-13 21:15:06 +00:00
parent c48352aa6c
commit 1e265247ca
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
21 changed files with 72 additions and 68 deletions

View File

@ -309,10 +309,10 @@ module Cask
appcast_contents, = curl_output("--compressed", "--user-agent", HOMEBREW_USER_AGENT_FAKE_SAFARI, "--location", appcast_contents, = curl_output("--compressed", "--user-agent", HOMEBREW_USER_AGENT_FAKE_SAFARI, "--location",
"--globoff", "--max-time", "5", appcast_stanza) "--globoff", "--max-time", "5", appcast_stanza)
version_stanza = cask.version.to_s version_stanza = cask.version.to_s
if cask.appcast.configuration.blank? adjusted_version_stanza = if cask.appcast.configuration.blank?
adjusted_version_stanza = version_stanza.split(",")[0].split("-")[0].split("_")[0] version_stanza.split(",")[0].split("-")[0].split("_")[0]
else else
adjusted_version_stanza = cask.appcast.configuration cask.appcast.configuration
end end
return if appcast_contents.include? adjusted_version_stanza return if appcast_contents.include? adjusted_version_stanza

View File

@ -103,10 +103,10 @@ module Homebrew
end end
def flag(*names, description: nil, required_for: nil, depends_on: nil) def flag(*names, description: nil, required_for: nil, depends_on: nil)
if names.any? { |name| name.end_with? "=" } required = if names.any? { |name| name.end_with? "=" }
required = OptionParser::REQUIRED_ARGUMENT OptionParser::REQUIRED_ARGUMENT
else else
required = OptionParser::OPTIONAL_ARGUMENT OptionParser::OPTIONAL_ARGUMENT
end end
names.map! { |name| name.chomp "=" } names.map! { |name| name.chomp "=" }
description = option_to_description(*names) if description.nil? description = option_to_description(*names) if description.nil?

View File

@ -63,10 +63,10 @@ module Homebrew
end end
# Description formatted to work well as page title when viewing gist # Description formatted to work well as page title when viewing gist
if f.core_formula? descr = if f.core_formula?
descr = "#{f.name} on #{OS_VERSION} - Homebrew build logs" "#{f.name} on #{OS_VERSION} - Homebrew build logs"
else else
descr = "#{f.name} (#{f.full_name}) on #{OS_VERSION} - Homebrew build logs" "#{f.name} (#{f.full_name}) on #{OS_VERSION} - Homebrew build logs"
end end
url = create_gist(files, descr) url = create_gist(files, descr)

View File

@ -40,10 +40,10 @@ module Homebrew
# superenv stopped adding brew's bin but generally users will want it # superenv stopped adding brew's bin but generally users will want it
ENV["PATH"] = PATH.new(ENV["PATH"]).insert(1, HOMEBREW_PREFIX/"bin") ENV["PATH"] = PATH.new(ENV["PATH"]).insert(1, HOMEBREW_PREFIX/"bin")
end end
if ENV["SHELL"].include?("zsh") ENV["PS1"] = if ENV["SHELL"].include?("zsh")
ENV["PS1"] = "brew %B%F{green}~%f%b$ " "brew %B%F{green}~%f%b$ "
else else
ENV["PS1"] = 'brew \[\033[1;32m\]\w\[\033[0m\]$ ' 'brew \[\033[1;32m\]\w\[\033[0m\]$ '
end end
ENV["VERBOSE"] = "1" ENV["VERBOSE"] = "1"
puts <<~EOS puts <<~EOS

View File

@ -27,10 +27,10 @@ module Homebrew
def tap_info def tap_info
tap_info_args.parse tap_info_args.parse
if args.installed? taps = if args.installed?
taps = Tap Tap
else else
taps = args.named.sort.map do |name| args.named.sort.map do |name|
Tap.fetch(name) Tap.fetch(name)
end end
end end

View File

@ -243,10 +243,10 @@ class Reporter
new_name = tap.formula_renames[old_name] new_name = tap.formula_renames[old_name]
next unless new_name next unless new_name
if tap.core_tap? new_full_name = if tap.core_tap?
new_full_name = new_name new_name
else else
new_full_name = "#{tap}/#{new_name}" "#{tap}/#{new_name}"
end end
renamed_formulae << [old_full_name, new_full_name] if @report[:A].include? new_full_name renamed_formulae << [old_full_name, new_full_name] if @report[:A].include? new_full_name
@ -257,10 +257,10 @@ class Reporter
old_name = tap.formula_renames.key(new_name) old_name = tap.formula_renames.key(new_name)
next unless old_name next unless old_name
if tap.core_tap? old_full_name = if tap.core_tap?
old_full_name = old_name old_name
else else
old_full_name = "#{tap}/#{old_name}" "#{tap}/#{old_name}"
end end
renamed_formulae << [old_full_name, new_full_name] renamed_formulae << [old_full_name, new_full_name]

View File

@ -306,10 +306,10 @@ module Homebrew
ohai "Detecting if #{filename} is relocatable..." if bottle_path.size > 1 * 1024 * 1024 ohai "Detecting if #{filename} is relocatable..." if bottle_path.size > 1 * 1024 * 1024
if Homebrew.default_prefix?(prefix) prefix_check = if Homebrew.default_prefix?(prefix)
prefix_check = File.join(prefix, "opt") File.join(prefix, "opt")
else else
prefix_check = prefix prefix
end end
# Ignore matches to source code, which is not required at run time. # Ignore matches to source code, which is not required at run time.

View File

@ -275,18 +275,18 @@ module Homebrew
if forced_version && forced_version != "0" if forced_version && forced_version != "0"
if requested_spec == :stable if requested_spec == :stable
if File.read(formula.path).include?("version \"#{old_formula_version}\"") replacement_pairs << if File.read(formula.path).include?("version \"#{old_formula_version}\"")
replacement_pairs << [ [
old_formula_version.to_s, old_formula_version.to_s,
forced_version, forced_version,
] ]
elsif new_mirrors elsif new_mirrors
replacement_pairs << [ [
/^( +)(mirror \"#{Regexp.escape(new_mirrors.last)}\"\n)/m, /^( +)(mirror \"#{Regexp.escape(new_mirrors.last)}\"\n)/m,
"\\1\\2\\1version \"#{forced_version}\"\n", "\\1\\2\\1version \"#{forced_version}\"\n",
] ]
else else
replacement_pairs << [ [
/^( +)(url \"#{Regexp.escape(new_url)}\"\n)/m, /^( +)(url \"#{Regexp.escape(new_url)}\"\n)/m,
"\\1\\2\\1version \"#{forced_version}\"\n", "\\1\\2\\1version \"#{forced_version}\"\n",
] ]

View File

@ -45,14 +45,14 @@ module Homebrew
[checksum.hash_type, checksum.hexdigest] [checksum.hash_type, checksum.hexdigest]
end end
if hash_type old = if hash_type
# insert replacement revision after hash # insert replacement revision after hash
old = <<~EOS <<~EOS
#{hash_type} "#{old_hash}" #{hash_type} "#{old_hash}"
EOS EOS
else else
# insert replacement revision after :revision # insert replacement revision after :revision
old = <<~EOS <<~EOS
:revision => "#{formula_spec.specs[:revision]}" :revision => "#{formula_spec.specs[:revision]}"
EOS EOS
end end

View File

@ -354,10 +354,10 @@ module Homebrew
patch_args = [] patch_args = []
# Normally we don't want whitespace errors, but squashing them can break # Normally we don't want whitespace errors, but squashing them can break
# patches so an option is provided to skip this step. # patches so an option is provided to skip this step.
if @args.ignore_whitespace? || @args.clean? patch_args << if @args.ignore_whitespace? || @args.clean?
patch_args << "--whitespace=nowarn" "--whitespace=nowarn"
else else
patch_args << "--whitespace=fix" "--whitespace=fix"
end end
# Fall back to three-way merge if patch does not apply cleanly # Fall back to three-way merge if patch does not apply cleanly

View File

@ -76,10 +76,10 @@ module SharedEnvExtension
value = value.to_s value = value.to_s
Array(keys).each do |key| Array(keys).each do |key|
old = self[key] old = self[key]
if old.nil? || old.empty? self[key] = if old.nil? || old.empty?
self[key] = value value
else else
self[key] = value + separator + old value + separator + old
end end
end end
end end

View File

@ -54,10 +54,10 @@ module Superenv
def homebrew_extra_library_paths def homebrew_extra_library_paths
paths = [] paths = []
if compiler == :llvm_clang if compiler == :llvm_clang
if !MacOS.sdk_path_if_needed paths << if !MacOS.sdk_path_if_needed
paths << "/usr/lib" "/usr/lib"
else else
paths << "#{MacOS.sdk_path}/usr/lib" "#{MacOS.sdk_path}/usr/lib"
end end
paths << Formula["llvm"].opt_lib.to_s paths << Formula["llvm"].opt_lib.to_s
end end

View File

@ -38,11 +38,11 @@ module Patch
{} {}
end.each_pair do |strip, urls| end.each_pair do |strip, urls|
Array(urls).each do |url| Array(urls).each do |url|
case url patch = case url
when :DATA when :DATA
patch = DATAPatch.new(strip) DATAPatch.new(strip)
else else
patch = LegacyPatch.new(strip, url) LegacyPatch.new(strip, url)
end end
patches << patch patches << patch
end end

View File

@ -46,10 +46,10 @@ class JavaRequirement < Requirement
def display_s def display_s
if @version if @version
if exact_version? op = if exact_version?
op = "=" "="
else else
op = ">=" ">="
end end
"#{name} #{op} #{version_without_plus}" "#{name} #{op} #{version_without_plus}"
else else

View File

@ -49,9 +49,10 @@ module RuboCop
lambda do |corrector| lambda do |corrector|
case node.type case node.type
when :str, :dstr when :str, :dstr
# Rubocop: intentionally outputted non-interpolated strings
corrector.replace(node.source_range, corrector.replace(node.source_range,
node.source.to_s.sub(%r{(/usr/local/(s?bin))}, node.source.to_s.sub(%r{(/usr/local/(s?bin))},
'#{\2}')) '#{\2}')) # rubocop:disable Lint/InterpolationCheck
when :int when :int
corrector.remove( corrector.remove(
range_with_surrounding_comma( range_with_surrounding_comma(

View File

@ -40,10 +40,10 @@ module RuboCop
node_begin_pos = start_column(node) node_begin_pos = start_column(node)
line_begin_pos = line_start_column(node) line_begin_pos = line_start_column(node)
if node_begin_pos == line_begin_pos @column = if node_begin_pos == line_begin_pos
@column = node_begin_pos + match_object.begin(0) - line_begin_pos node_begin_pos + match_object.begin(0) - line_begin_pos
else else
@column = node_begin_pos + match_object.begin(0) - line_begin_pos + 1 node_begin_pos + match_object.begin(0) - line_begin_pos + 1
end end
@length = match_object.to_s.length @length = match_object.to_s.length
@line_no = line_number(node) @line_no = line_number(node)
@ -200,10 +200,10 @@ module RuboCop
# Returns true if given dependency name and dependency type exist in given dependency method call node. # Returns true if given dependency name and dependency type exist in given dependency method call node.
# TODO: Add case where key of hash is an array # TODO: Add case where key of hash is an array
def depends_on_name_type?(node, name = nil, type = :required) def depends_on_name_type?(node, name = nil, type = :required)
if name name_match = if name
name_match = false false
else else
name_match = true # Match only by type when name is nil true # Match only by type when name is nil
end end
case type case type

View File

@ -24,10 +24,10 @@ module Homebrew
args = %w[ args = %w[
--force-exclusion --force-exclusion
] ]
if fix args << if fix
args << "--auto-correct" "--auto-correct"
else else
args << "--parallel" "--parallel"
end end
args += ["--extra-details", "--display-cop-names"] if Homebrew.args.verbose? args += ["--extra-details", "--display-cop-names"] if Homebrew.args.verbose?

View File

@ -81,10 +81,10 @@ class Tab < OpenStruct
if attributes["source"]["spec"].nil? if attributes["source"]["spec"].nil?
version = PkgVersion.parse path.to_s.split("/").second_to_last version = PkgVersion.parse path.to_s.split("/").second_to_last
if version.head? attributes["source"]["spec"] = if version.head?
attributes["source"]["spec"] = "head" "head"
else else
attributes["source"]["spec"] = "stable" "stable"
end end
end end
@ -360,10 +360,10 @@ class Tab < OpenStruct
def to_s def to_s
s = [] s = []
if poured_from_bottle s << if poured_from_bottle
s << "Poured from bottle" "Poured from bottle"
else else
s << "Built from source" "Built from source"
end end
s << Time.at(time).strftime("on %Y-%m-%d at %H:%M:%S") if time s << Time.at(time).strftime("on %Y-%m-%d at %H:%M:%S") if time

View File

@ -187,6 +187,8 @@ module Homebrew
end end
end end
# Intentionally outputted non-interpolated strings
# rubocop:disable Lint/InterpolationCheck
describe "#line_problems" do describe "#line_problems" do
specify "pkgshare" do specify "pkgshare" do
fa = formula_auditor "foo", <<~RUBY, strict: true fa = formula_auditor "foo", <<~RUBY, strict: true
@ -237,6 +239,7 @@ module Homebrew
.to eq('Use pkgshare instead of (share/"foolibc++")') .to eq('Use pkgshare instead of (share/"foolibc++")')
end end
end end
# rubocop:enable Lint/InterpolationCheck
describe "#audit_github_repository" do describe "#audit_github_repository" do
specify "#audit_github_repository when HOMEBREW_NO_GITHUB_API is set" do specify "#audit_github_repository when HOMEBREW_NO_GITHUB_API is set" do

View File

@ -46,10 +46,10 @@ module Utils
name = receipt_file_path.split("/").first name = receipt_file_path.split("/").first
tap = Tab.from_file_content(receipt_file, "#{bottle_file}/#{receipt_file_path}").tap tap = Tab.from_file_content(receipt_file, "#{bottle_file}/#{receipt_file_path}").tap
if tap.nil? || tap.core_tap? full_name = if tap.nil? || tap.core_tap?
full_name = name name
else else
full_name = "#{tap}/#{name}" "#{tap}/#{name}"
end end
[name, full_name] [name, full_name]

View File

@ -48,13 +48,13 @@ module GitHub
def initialize(github_message) def initialize(github_message)
@github_message = github_message @github_message = github_message
message = +"GitHub #{github_message}:" message = +"GitHub #{github_message}:"
if ENV["HOMEBREW_GITHUB_API_TOKEN"] message << if ENV["HOMEBREW_GITHUB_API_TOKEN"]
message << <<~EOS <<~EOS
HOMEBREW_GITHUB_API_TOKEN may be invalid or expired; check: HOMEBREW_GITHUB_API_TOKEN may be invalid or expired; check:
#{Formatter.url("https://github.com/settings/tokens")} #{Formatter.url("https://github.com/settings/tokens")}
EOS EOS
else else
message << <<~EOS <<~EOS
The GitHub credentials in the macOS keychain may be invalid. The GitHub credentials in the macOS keychain may be invalid.
Clear them with: Clear them with:
printf "protocol=https\\nhost=github.com\\n" | git credential-osxkeychain erase printf "protocol=https\\nhost=github.com\\n" | git credential-osxkeychain erase