mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Rubocop: automatic rule fixes.
This commit is contained in:
parent
9eb51db400
commit
01e9ec9a9f
@ -56,7 +56,7 @@ module Hbc
|
|||||||
|
|
||||||
class FromURILoader < FromPathLoader
|
class FromURILoader < FromPathLoader
|
||||||
def self.can_load?(ref)
|
def self.can_load?(ref)
|
||||||
ref.to_s.match?(::URI.regexp)
|
ref.to_s.match?(::URI::DEFAULT_PARSER.make_regexp)
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :url
|
attr_reader :url
|
||||||
|
@ -161,7 +161,7 @@ module Hbc
|
|||||||
begin
|
begin
|
||||||
DSL::Container.new(*args).tap do |container|
|
DSL::Container.new(*args).tap do |container|
|
||||||
# TODO: remove this backward-compatibility section after removing nested_container
|
# TODO: remove this backward-compatibility section after removing nested_container
|
||||||
if container && container.nested
|
if container&.nested
|
||||||
artifacts[:nested_container] << Artifact::NestedContainer.new(cask, container.nested)
|
artifacts[:nested_container] << Artifact::NestedContainer.new(cask, container.nested)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -159,7 +159,7 @@ module Hbc
|
|||||||
odebug "Extracting primary container"
|
odebug "Extracting primary container"
|
||||||
|
|
||||||
FileUtils.mkdir_p @cask.staged_path
|
FileUtils.mkdir_p @cask.staged_path
|
||||||
container = if @cask.container && @cask.container.type
|
container = if @cask.container&.type
|
||||||
Container.from_type(@cask.container.type)
|
Container.from_type(@cask.container.type)
|
||||||
else
|
else
|
||||||
Container.for_path(@downloaded_path, @command)
|
Container.for_path(@downloaded_path, @command)
|
||||||
@ -361,7 +361,7 @@ module Hbc
|
|||||||
|
|
||||||
savedir = @cask.metadata_subdir("Casks", timestamp: :now, create: true)
|
savedir = @cask.metadata_subdir("Casks", timestamp: :now, create: true)
|
||||||
FileUtils.copy @cask.sourcefile_path, savedir
|
FileUtils.copy @cask.sourcefile_path, savedir
|
||||||
old_savedir.rmtree unless old_savedir.nil?
|
old_savedir&.rmtree
|
||||||
end
|
end
|
||||||
|
|
||||||
def uninstall
|
def uninstall
|
||||||
|
@ -61,7 +61,7 @@ module Hbc
|
|||||||
end
|
end
|
||||||
|
|
||||||
def assert_success
|
def assert_success
|
||||||
return if processed_status && processed_status.success?
|
return if processed_status&.success?
|
||||||
raise CaskCommandFailedError.new(command, processed_output[:stdout], processed_output[:stderr], processed_status)
|
raise CaskCommandFailedError.new(command, processed_output[:stdout], processed_output[:stderr], processed_status)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ class Caveats
|
|||||||
|
|
||||||
def plist_caveats
|
def plist_caveats
|
||||||
s = []
|
s = []
|
||||||
if f.plist || (keg && keg.plist_installed?)
|
if f.plist || (keg&.plist_installed?)
|
||||||
plist_domain = f.plist_path.basename(".plist")
|
plist_domain = f.plist_path.basename(".plist")
|
||||||
|
|
||||||
# we readlink because this path probably doesn't exist since caveats
|
# we readlink because this path probably doesn't exist since caveats
|
||||||
|
@ -77,7 +77,7 @@ module Homebrew
|
|||||||
def unlinkapps_unlink?(target_app, opts = {})
|
def unlinkapps_unlink?(target_app, opts = {})
|
||||||
# Skip non-symlinks and symlinks that don't point into the Homebrew prefix.
|
# Skip non-symlinks and symlinks that don't point into the Homebrew prefix.
|
||||||
app = target_app.readlink.to_s if target_app.symlink?
|
app = target_app.readlink.to_s if target_app.symlink?
|
||||||
return false unless app && app.start_with?(*UNLINKAPPS_PREFIXES)
|
return false unless app&.start_with?(*UNLINKAPPS_PREFIXES)
|
||||||
|
|
||||||
if opts.fetch(:prune, false)
|
if opts.fetch(:prune, false)
|
||||||
!File.exist?(app) # Remove only broken symlinks in prune mode.
|
!File.exist?(app) # Remove only broken symlinks in prune mode.
|
||||||
|
@ -16,7 +16,7 @@ module IRB
|
|||||||
workspace = WorkSpace.new(binding)
|
workspace = WorkSpace.new(binding)
|
||||||
irb = Irb.new(workspace)
|
irb = Irb.new(workspace)
|
||||||
|
|
||||||
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
|
@CONF[:IRB_RC]&.call(irb.context)
|
||||||
@CONF[:MAIN_CONTEXT] = irb.context
|
@CONF[:MAIN_CONTEXT] = irb.context
|
||||||
|
|
||||||
trap("SIGINT") do
|
trap("SIGINT") do
|
||||||
|
@ -51,7 +51,7 @@ class Dependency
|
|||||||
end
|
end
|
||||||
|
|
||||||
def modify_build_environment
|
def modify_build_environment
|
||||||
env_proc.call unless env_proc.nil?
|
env_proc&.call
|
||||||
end
|
end
|
||||||
|
|
||||||
def inspect
|
def inspect
|
||||||
|
@ -707,7 +707,7 @@ class FormulaAuditor
|
|||||||
end
|
end
|
||||||
|
|
||||||
stable = formula.stable
|
stable = formula.stable
|
||||||
case stable && stable.url
|
case stable&.url
|
||||||
when /[\d\._-](alpha|beta|rc\d)/
|
when /[\d\._-](alpha|beta|rc\d)/
|
||||||
matched = Regexp.last_match(1)
|
matched = Regexp.last_match(1)
|
||||||
version_prefix = stable.version.to_s.sub(/\d+$/, "")
|
version_prefix = stable.version.to_s.sub(/\d+$/, "")
|
||||||
@ -1018,7 +1018,7 @@ class FormulaAuditor
|
|||||||
def audit_reverse_migration
|
def audit_reverse_migration
|
||||||
# Only enforce for new formula being re-added to core and official taps
|
# Only enforce for new formula being re-added to core and official taps
|
||||||
return unless @strict
|
return unless @strict
|
||||||
return unless formula.tap && formula.tap.official?
|
return unless formula.tap&.official?
|
||||||
return unless formula.tap.tap_migrations.key?(formula.name)
|
return unless formula.tap.tap_migrations.key?(formula.name)
|
||||||
|
|
||||||
problem <<-EOS.undent
|
problem <<-EOS.undent
|
||||||
|
@ -283,7 +283,7 @@ module Homebrew
|
|||||||
raise
|
raise
|
||||||
ensure
|
ensure
|
||||||
ignore_interrupts do
|
ignore_interrupts do
|
||||||
original_tab.write if original_tab
|
original_tab&.write
|
||||||
unless ARGV.include? "--skip-relocation"
|
unless ARGV.include? "--skip-relocation"
|
||||||
keg.replace_placeholders_with_locations changed_files
|
keg.replace_placeholders_with_locations changed_files
|
||||||
end
|
end
|
||||||
|
@ -124,7 +124,7 @@ module Homebrew
|
|||||||
Formula.each do |f|
|
Formula.each do |f|
|
||||||
if is_devel && f.devel && f.devel.url && f.devel.url.match(base_url)
|
if is_devel && f.devel && f.devel.url && f.devel.url.match(base_url)
|
||||||
guesses << f
|
guesses << f
|
||||||
elsif f.stable && f.stable.url && f.stable.url.match(base_url)
|
elsif f.stable&.url && f.stable.url.match(base_url)
|
||||||
guesses << f
|
guesses << f
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -75,7 +75,7 @@ module Homebrew
|
|||||||
tap = CoreTap.instance
|
tap = CoreTap.instance
|
||||||
elsif (testing_match = arg.match %r{/job/Homebrew.*Testing/(\d+)/})
|
elsif (testing_match = arg.match %r{/job/Homebrew.*Testing/(\d+)/})
|
||||||
tap = ARGV.value("tap")
|
tap = ARGV.value("tap")
|
||||||
tap = if tap && tap.start_with?("homebrew/")
|
tap = if tap&.start_with?("homebrew/")
|
||||||
Tap.fetch("homebrew", tap.strip_prefix("homebrew/"))
|
Tap.fetch("homebrew", tap.strip_prefix("homebrew/"))
|
||||||
elsif tap
|
elsif tap
|
||||||
odie "Tap option did not start with \"homebrew/\": #{tap}"
|
odie "Tap option did not start with \"homebrew/\": #{tap}"
|
||||||
@ -350,7 +350,7 @@ module Homebrew
|
|||||||
files << Regexp.last_match(1) if line =~ %r{^\+\+\+ b/(.*)}
|
files << Regexp.last_match(1) if line =~ %r{^\+\+\+ b/(.*)}
|
||||||
end
|
end
|
||||||
files.each do |file|
|
files.each do |file|
|
||||||
if tap && tap.formula_file?(file)
|
if tap&.formula_file?(file)
|
||||||
formula_name = File.basename(file, ".rb")
|
formula_name = File.basename(file, ".rb")
|
||||||
formulae << formula_name unless formulae.include?(formula_name)
|
formulae << formula_name unless formulae.include?(formula_name)
|
||||||
else
|
else
|
||||||
|
@ -10,10 +10,8 @@ module Homebrew
|
|||||||
|
|
||||||
def release_notes
|
def release_notes
|
||||||
previous_tag = ARGV.named.first
|
previous_tag = ARGV.named.first
|
||||||
unless previous_tag
|
previous_tag ||= Utils.popen_read("git tag --list --sort=-version:refname")
|
||||||
previous_tag = Utils.popen_read("git tag --list --sort=-version:refname")
|
|
||||||
.lines.first.chomp
|
.lines.first.chomp
|
||||||
end
|
|
||||||
odie "Could not find any previous tags!" unless previous_tag
|
odie "Could not find any previous tags!" unless previous_tag
|
||||||
|
|
||||||
end_ref = ARGV.named[1] || "origin/master"
|
end_ref = ARGV.named[1] || "origin/master"
|
||||||
|
@ -522,7 +522,7 @@ module Homebrew
|
|||||||
homebrew_owned = @found.all? do |path|
|
homebrew_owned = @found.all? do |path|
|
||||||
Pathname.new(path).realpath.to_s.start_with? "#{HOMEBREW_CELLAR}/gettext"
|
Pathname.new(path).realpath.to_s.start_with? "#{HOMEBREW_CELLAR}/gettext"
|
||||||
end
|
end
|
||||||
return if gettext && gettext.linked_keg.directory? && homebrew_owned
|
return if gettext&.linked_keg&.directory? && homebrew_owned
|
||||||
|
|
||||||
inject_file_list @found, <<-EOS.undent
|
inject_file_list @found, <<-EOS.undent
|
||||||
gettext files detected at a system prefix.
|
gettext files detected at a system prefix.
|
||||||
@ -540,7 +540,7 @@ module Homebrew
|
|||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
if libiconv && libiconv.linked_keg.directory?
|
if libiconv&.linked_keg&.directory?
|
||||||
unless libiconv.keg_only?
|
unless libiconv.keg_only?
|
||||||
<<-EOS.undent
|
<<-EOS.undent
|
||||||
A libiconv formula is installed and linked.
|
A libiconv formula is installed and linked.
|
||||||
|
@ -144,7 +144,7 @@ module HomebrewArgvExtension
|
|||||||
def value(name)
|
def value(name)
|
||||||
arg_prefix = "--#{name}="
|
arg_prefix = "--#{name}="
|
||||||
flag_with_value = find { |arg| arg.start_with?(arg_prefix) }
|
flag_with_value = find { |arg| arg.start_with?(arg_prefix) }
|
||||||
flag_with_value.strip_prefix(arg_prefix) if flag_with_value
|
flag_with_value&.strip_prefix(arg_prefix)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of values that were given as a comma-separated list.
|
# Returns an array of values that were given as a comma-separated list.
|
||||||
@ -236,7 +236,7 @@ module HomebrewArgvExtension
|
|||||||
|
|
||||||
def bottle_arch
|
def bottle_arch
|
||||||
arch = value "bottle-arch"
|
arch = value "bottle-arch"
|
||||||
arch.to_sym if arch
|
arch&.to_sym
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_from_source?
|
def build_from_source?
|
||||||
|
@ -472,7 +472,7 @@ class Formula
|
|||||||
return true if devel && tab.devel_version && tab.devel_version < devel.version
|
return true if devel && tab.devel_version && tab.devel_version < devel.version
|
||||||
|
|
||||||
if options[:fetch_head]
|
if options[:fetch_head]
|
||||||
return false unless head && head.downloader.is_a?(VCSDownloadStrategy)
|
return false unless head&.downloader.is_a?(VCSDownloadStrategy)
|
||||||
downloader = head.downloader
|
downloader = head.downloader
|
||||||
downloader.shutup! unless ARGV.verbose?
|
downloader.shutup! unless ARGV.verbose?
|
||||||
downloader.commit_outdated?(version.version.commit)
|
downloader.commit_outdated?(version.version.commit)
|
||||||
@ -1115,8 +1115,8 @@ class Formula
|
|||||||
|
|
||||||
# @private
|
# @private
|
||||||
def unlock
|
def unlock
|
||||||
@lock.unlock unless @lock.nil?
|
@lock&.unlock
|
||||||
@oldname_lock.unlock unless @oldname_lock.nil?
|
@oldname_lock&.unlock
|
||||||
end
|
end
|
||||||
|
|
||||||
def migration_needed?
|
def migration_needed?
|
||||||
@ -1440,7 +1440,7 @@ class Formula
|
|||||||
# True if this formula is provided by Homebrew itself
|
# True if this formula is provided by Homebrew itself
|
||||||
# @private
|
# @private
|
||||||
def core_formula?
|
def core_formula?
|
||||||
tap && tap.core_tap?
|
tap&.core_tap?
|
||||||
end
|
end
|
||||||
|
|
||||||
# True if this formula is provided by external Tap
|
# True if this formula is provided by external Tap
|
||||||
@ -1525,10 +1525,10 @@ class Formula
|
|||||||
"oldname" => oldname,
|
"oldname" => oldname,
|
||||||
"aliases" => aliases,
|
"aliases" => aliases,
|
||||||
"versions" => {
|
"versions" => {
|
||||||
"stable" => (stable.version.to_s if stable),
|
"stable" => stable&.version.to_s,
|
||||||
"bottle" => bottle ? true : false,
|
"bottle" => bottle ? true : false,
|
||||||
"devel" => (devel.version.to_s if devel),
|
"devel" => devel&.version.to_s,
|
||||||
"head" => (head.version.to_s if head),
|
"head" => head&.version.to_s,
|
||||||
},
|
},
|
||||||
"revision" => revision,
|
"revision" => revision,
|
||||||
"version_scheme" => version_scheme,
|
"version_scheme" => version_scheme,
|
||||||
|
@ -560,7 +560,7 @@ class FormulaInstaller
|
|||||||
end
|
end
|
||||||
raise
|
raise
|
||||||
else
|
else
|
||||||
ignore_interrupts { tmp_keg.rmtree if tmp_keg && tmp_keg.directory? }
|
ignore_interrupts { tmp_keg.rmtree if tmp_keg&.directory? }
|
||||||
end
|
end
|
||||||
|
|
||||||
def caveats
|
def caveats
|
||||||
|
@ -338,7 +338,7 @@ class Keg
|
|||||||
dir if dir.directory? && dir.children.any? { |f| f.basename.to_s.start_with?("_") }
|
dir if dir.directory? && dir.children.any? { |f| f.basename.to_s.start_with?("_") }
|
||||||
when :fish then path/"share/fish/vendor_completions.d"
|
when :fish then path/"share/fish/vendor_completions.d"
|
||||||
end
|
end
|
||||||
dir && dir.directory? && !dir.children.empty?
|
dir&.directory? && !dir.children.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
def functions_installed?(shell)
|
def functions_installed?(shell)
|
||||||
|
@ -23,7 +23,7 @@ module Language
|
|||||||
else
|
else
|
||||||
homebrew_site_packages(version)
|
homebrew_site_packages(version)
|
||||||
end
|
end
|
||||||
block.call python, version if block
|
block&.call python, version
|
||||||
end
|
end
|
||||||
ENV["PYTHONPATH"] = original_pythonpath
|
ENV["PYTHONPATH"] = original_pythonpath
|
||||||
end
|
end
|
||||||
|
@ -104,7 +104,7 @@ module OS
|
|||||||
# Returns the path to an SDK or nil, following the rules set by #sdk.
|
# Returns the path to an SDK or nil, following the rules set by #sdk.
|
||||||
def sdk_path(v = nil)
|
def sdk_path(v = nil)
|
||||||
s = sdk(v)
|
s = sdk(v)
|
||||||
s.path unless s.nil?
|
s&.path
|
||||||
end
|
end
|
||||||
|
|
||||||
# See these issues for some history:
|
# See these issues for some history:
|
||||||
|
@ -69,14 +69,14 @@ class JavaRequirement < Requirement
|
|||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
javas << jdk.bin/"java" if jdk && jdk.installed?
|
javas << jdk.bin/"java" if jdk&.installed?
|
||||||
javas << which("java")
|
javas << which("java")
|
||||||
javas
|
javas
|
||||||
end
|
end
|
||||||
|
|
||||||
def preferred_java
|
def preferred_java
|
||||||
possible_javas.detect do |java|
|
possible_javas.detect do |java|
|
||||||
next false unless java && java.executable?
|
next false unless java&.executable?
|
||||||
next true unless @version
|
next true unless @version
|
||||||
next true if satisfies_version(java)
|
next true if satisfies_version(java)
|
||||||
end
|
end
|
||||||
|
@ -41,9 +41,7 @@ class RubyRequirement < Requirement
|
|||||||
def rubies
|
def rubies
|
||||||
rubies = which_all("ruby")
|
rubies = which_all("ruby")
|
||||||
ruby_formula = Formula["ruby"]
|
ruby_formula = Formula["ruby"]
|
||||||
if ruby_formula && ruby_formula.installed?
|
rubies.unshift ruby_formula.bin/"ruby" if ruby_formula&.installed?
|
||||||
rubies.unshift ruby_formula.bin/"ruby"
|
|
||||||
end
|
|
||||||
rubies.uniq
|
rubies.uniq
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -167,7 +167,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]
|
||||||
|
@ -324,7 +324,7 @@ class Tab < OpenStruct
|
|||||||
"poured_from_bottle" => poured_from_bottle,
|
"poured_from_bottle" => poured_from_bottle,
|
||||||
"installed_as_dependency" => installed_as_dependency,
|
"installed_as_dependency" => installed_as_dependency,
|
||||||
"installed_on_request" => installed_on_request,
|
"installed_on_request" => installed_on_request,
|
||||||
"changed_files" => changed_files && changed_files.map(&:to_s),
|
"changed_files" => changed_files&.map(&:to_s),
|
||||||
"time" => time,
|
"time" => time,
|
||||||
"source_modified_time" => source_modified_time.to_i,
|
"source_modified_time" => source_modified_time.to_i,
|
||||||
"HEAD" => self.HEAD,
|
"HEAD" => self.HEAD,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user