Merge pull request #20578 from Homebrew/dug/t-must-cleanup
Remove unnecessary use of `T.must`
This commit is contained in:
commit
12a31a1f6a
@ -43,7 +43,7 @@ module Homebrew
|
|||||||
next if !only.empty? && only.exclude?(name)
|
next if !only.empty? && only.exclude?(name)
|
||||||
|
|
||||||
lines.reject! { |line| line.start_with?("#") || line =~ /^\s*$/ }
|
lines.reject! { |line| line.start_with?("#") || line =~ /^\s*$/ }
|
||||||
first_line = T.must(lines.first)
|
first_line = lines.fetch(0)
|
||||||
command = first_line.chomp
|
command = first_line.chomp
|
||||||
command.sub!(/ \$\*$/, "")
|
command.sub!(/ \$\*$/, "")
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ module Cask
|
|||||||
tokens.sort.filter_map do |token|
|
tokens.sort.filter_map do |token|
|
||||||
CaskLoader.load_prefer_installed(token, config:, warn: false)
|
CaskLoader.load_prefer_installed(token, config:, warn: false)
|
||||||
rescue TapCaskAmbiguityError => e
|
rescue TapCaskAmbiguityError => e
|
||||||
T.must(e.loaders.first).load(config:)
|
e.loaders.fetch(0).load(config:)
|
||||||
rescue
|
rescue
|
||||||
# Don't blow up because of a single unavailable cask.
|
# Don't blow up because of a single unavailable cask.
|
||||||
nil
|
nil
|
||||||
|
@ -91,7 +91,7 @@ module Homebrew
|
|||||||
raise UsageError, "`brew deps --os=all` is not supported." if args.os == "all"
|
raise UsageError, "`brew deps --os=all` is not supported." if args.os == "all"
|
||||||
raise UsageError, "`brew deps --arch=all` is not supported." if args.arch == "all"
|
raise UsageError, "`brew deps --arch=all` is not supported." if args.arch == "all"
|
||||||
|
|
||||||
os, arch = T.must(args.os_arch_combinations.first)
|
os, arch = args.os_arch_combinations.fetch(0)
|
||||||
eval_all = args.eval_all?
|
eval_all = args.eval_all?
|
||||||
|
|
||||||
Formulary.enable_factory_cache!
|
Formulary.enable_factory_cache!
|
||||||
|
@ -44,7 +44,7 @@ module Homebrew
|
|||||||
if args.no_named?
|
if args.no_named?
|
||||||
git_log(HOMEBREW_REPOSITORY)
|
git_log(HOMEBREW_REPOSITORY)
|
||||||
else
|
else
|
||||||
path = T.must(args.named.to_paths.first)
|
path = args.named.to_paths.fetch(0)
|
||||||
tap = Tap.from_path(path)
|
tap = Tap.from_path(path)
|
||||||
git_log path.dirname, path, tap
|
git_log path.dirname, path, tap
|
||||||
end
|
end
|
||||||
|
@ -49,7 +49,7 @@ module Homebrew
|
|||||||
sig { params(tap: Tap).returns(T::Array[Formula]) }
|
sig { params(tap: Tap).returns(T::Array[Formula]) }
|
||||||
def installed_formulae_for(tap:)
|
def installed_formulae_for(tap:)
|
||||||
tap.formula_names.filter_map do |formula_name|
|
tap.formula_names.filter_map do |formula_name|
|
||||||
next unless installed_formulae_names.include?(T.must(formula_name.split("/").last))
|
next unless installed_formulae_names.include?(formula_name.split("/").fetch(-1))
|
||||||
|
|
||||||
formula = begin
|
formula = begin
|
||||||
Formulary.factory(formula_name)
|
Formulary.factory(formula_name)
|
||||||
@ -68,7 +68,7 @@ module Homebrew
|
|||||||
sig { params(tap: Tap).returns(T::Array[Cask::Cask]) }
|
sig { params(tap: Tap).returns(T::Array[Cask::Cask]) }
|
||||||
def installed_casks_for(tap:)
|
def installed_casks_for(tap:)
|
||||||
tap.cask_tokens.filter_map do |cask_token|
|
tap.cask_tokens.filter_map do |cask_token|
|
||||||
next unless installed_cask_tokens.include?(T.must(cask_token.split("/").last))
|
next unless installed_cask_tokens.include?(cask_token.split("/").fetch(-1))
|
||||||
|
|
||||||
cask = begin
|
cask = begin
|
||||||
Cask::CaskLoader.load(cask_token)
|
Cask::CaskLoader.load(cask_token)
|
||||||
|
@ -500,7 +500,7 @@ class Reporter
|
|||||||
case status
|
case status
|
||||||
when "A", "D"
|
when "A", "D"
|
||||||
full_name = tap.formula_file_to_name(src)
|
full_name = tap.formula_file_to_name(src)
|
||||||
name = T.must(full_name.split("/").last)
|
name = full_name.split("/").fetch(-1)
|
||||||
new_tap = tap.tap_migrations[name]
|
new_tap = tap.tap_migrations[name]
|
||||||
@report[T.must(status).to_sym] << full_name unless new_tap
|
@report[T.must(status).to_sym] << full_name unless new_tap
|
||||||
when "M"
|
when "M"
|
||||||
@ -614,7 +614,7 @@ class Reporter
|
|||||||
sig { void }
|
sig { void }
|
||||||
def migrate_tap_migration
|
def migrate_tap_migration
|
||||||
(Array(report[:D]) + Array(report[:DC])).each do |full_name|
|
(Array(report[:D]) + Array(report[:DC])).each do |full_name|
|
||||||
name = T.must(full_name.split("/").last)
|
name = full_name.split("/").fetch(-1)
|
||||||
new_tap_name = tap.tap_migrations[name]
|
new_tap_name = tap.tap_migrations[name]
|
||||||
next if new_tap_name.nil? # skip if not in tap_migrations list.
|
next if new_tap_name.nil? # skip if not in tap_migrations list.
|
||||||
|
|
||||||
@ -901,7 +901,7 @@ class ReporterHub
|
|||||||
true
|
true
|
||||||
end
|
end
|
||||||
casks.each do |cask|
|
casks.each do |cask|
|
||||||
cask_token = T.must(cask.split("/").last)
|
cask_token = cask.split("/").fetch(-1)
|
||||||
if should_display_descriptions && (desc = cask_description(cask))
|
if should_display_descriptions && (desc = cask_description(cask))
|
||||||
puts "#{cask_token}: #{desc}"
|
puts "#{cask_token}: #{desc}"
|
||||||
else
|
else
|
||||||
@ -924,7 +924,7 @@ class ReporterHub
|
|||||||
return if Homebrew::SimulateSystem.simulating_or_running_on_linux?
|
return if Homebrew::SimulateSystem.simulating_or_running_on_linux?
|
||||||
|
|
||||||
casks = select_formula_or_cask(:DC).sort.filter_map do |name|
|
casks = select_formula_or_cask(:DC).sort.filter_map do |name|
|
||||||
name = T.must(name.split("/").last)
|
name = name.split("/").fetch(-1)
|
||||||
pretty_uninstalled(name) if cask_installed?(name)
|
pretty_uninstalled(name) if cask_installed?(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ module Homebrew
|
|||||||
odie "`brew audit` failed for #{commit[:formula_name]}!"
|
odie "`brew audit` failed for #{commit[:formula_name]}!"
|
||||||
end
|
end
|
||||||
|
|
||||||
new_formula_version = T.must(commits.first)[:new_version]
|
new_formula_version = commits.fetch(0)[:new_version]
|
||||||
|
|
||||||
pr_title = if args.bump_synced.nil?
|
pr_title = if args.bump_synced.nil?
|
||||||
"#{formula.name} #{new_formula_version}"
|
"#{formula.name} #{new_formula_version}"
|
||||||
|
@ -1332,7 +1332,7 @@ module Formulary
|
|||||||
if (possible_alias = tap.alias_table[alias_table_key].presence)
|
if (possible_alias = tap.alias_table[alias_table_key].presence)
|
||||||
# FIXME: Remove the need to split the name and instead make
|
# FIXME: Remove the need to split the name and instead make
|
||||||
# the alias table only contain short names.
|
# the alias table only contain short names.
|
||||||
name = T.must(possible_alias.split("/").last)
|
name = possible_alias.split("/").fetch(-1)
|
||||||
type = :alias
|
type = :alias
|
||||||
elsif (new_name = tap.formula_renames[name].presence)
|
elsif (new_name = tap.formula_renames[name].presence)
|
||||||
old_name = tap.core_tap? ? name : tapped_name
|
old_name = tap.core_tap? ? name : tapped_name
|
||||||
|
@ -252,7 +252,7 @@ module Language
|
|||||||
raise FormulaUnknownPythonError, self if wanted.empty?
|
raise FormulaUnknownPythonError, self if wanted.empty?
|
||||||
raise FormulaAmbiguousPythonError, self if wanted.size > 1
|
raise FormulaAmbiguousPythonError, self if wanted.size > 1
|
||||||
|
|
||||||
python = T.must(wanted.first)
|
python = wanted.fetch(0)
|
||||||
python = "python3" if python == "python"
|
python = "python3" if python == "python"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ begin
|
|||||||
|
|
||||||
trap("INT", old_trap)
|
trap("INT", old_trap)
|
||||||
|
|
||||||
formula = T.must(args.named.to_resolved_formulae.first)
|
formula = args.named.to_resolved_formulae.fetch(0)
|
||||||
if args.debug? && !Homebrew::EnvConfig.disable_debrew?
|
if args.debug? && !Homebrew::EnvConfig.disable_debrew?
|
||||||
require "debrew"
|
require "debrew"
|
||||||
formula.extend(Debrew::Formula)
|
formula.extend(Debrew::Formula)
|
||||||
|
@ -37,7 +37,7 @@ begin
|
|||||||
raise "Cannot kill child processes without `pkill`, please install!" unless which("pkill")
|
raise "Cannot kill child processes without `pkill`, please install!" unless which("pkill")
|
||||||
end
|
end
|
||||||
|
|
||||||
formula = T.must(args.named.to_resolved_formulae.first)
|
formula = args.named.to_resolved_formulae.fetch(0)
|
||||||
formula.extend(Homebrew::Assertions)
|
formula.extend(Homebrew::Assertions)
|
||||||
formula.extend(Homebrew::FreePort)
|
formula.extend(Homebrew::FreePort)
|
||||||
if args.debug? && !Homebrew::EnvConfig.disable_debrew?
|
if args.debug? && !Homebrew::EnvConfig.disable_debrew?
|
||||||
|
@ -59,7 +59,7 @@ module UnpackStrategy
|
|||||||
}
|
}
|
||||||
def subextract(extractor, dir, verbose)
|
def subextract(extractor, dir, verbose)
|
||||||
extractor.new(path).extract(to: dir, verbose:)
|
extractor.new(path).extract(to: dir, verbose:)
|
||||||
T.must(dir.children.first)
|
dir.children.fetch(0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -313,7 +313,7 @@ module Utils
|
|||||||
)
|
)
|
||||||
next if last_thirty_days_match.blank?
|
next if last_thirty_days_match.blank?
|
||||||
|
|
||||||
last_thirty_days_downloads = T.must(last_thirty_days_match.captures.first).tr(",", "")
|
last_thirty_days_downloads = last_thirty_days_match.captures.fetch(0).tr(",", "")
|
||||||
thirty_day_download_count += if (millions_match = last_thirty_days_downloads.match(/(\d+\.\d+)M/).presence)
|
thirty_day_download_count += if (millions_match = last_thirty_days_downloads.match(/(\d+\.\d+)M/).presence)
|
||||||
(millions_match.captures.first.to_f * 1_000_000).to_i
|
(millions_match.captures.first.to_f * 1_000_000).to_i
|
||||||
else
|
else
|
||||||
|
@ -180,7 +180,7 @@ module CPAN
|
|||||||
|
|
||||||
ohai "Updating resource blocks" unless silent
|
ohai "Updating resource blocks" unless silent
|
||||||
Utils::Inreplace.inreplace formula.path do |s|
|
Utils::Inreplace.inreplace formula.path do |s|
|
||||||
if T.must(s.inreplace_string.split(/^ test do\b/, 2).first).scan(inreplace_regex).length > 1
|
if s.inreplace_string.split(/^ test do\b/, 2).fetch(0).scan(inreplace_regex).length > 1
|
||||||
odie "Unable to update resource blocks for \"#{formula.name}\" automatically. Please update them manually."
|
odie "Unable to update resource blocks for \"#{formula.name}\" automatically. Please update them manually."
|
||||||
end
|
end
|
||||||
s.sub! inreplace_regex, resource_section
|
s.sub! inreplace_regex, resource_section
|
||||||
|
@ -109,7 +109,7 @@ module Utils
|
|||||||
raise Interrupt if $CHILD_STATUS.termsig == Signal.list["INT"]
|
raise Interrupt if $CHILD_STATUS.termsig == Signal.list["INT"]
|
||||||
|
|
||||||
if data.present?
|
if data.present?
|
||||||
error_hash = JSON.parse(T.must(data.lines.first))
|
error_hash = JSON.parse(data.lines.fetch(0))
|
||||||
raise rewrite_child_error(error_hash)
|
raise rewrite_child_error(error_hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -441,7 +441,7 @@ module PyPI
|
|||||||
|
|
||||||
ohai "Updating resource blocks" unless silent
|
ohai "Updating resource blocks" unless silent
|
||||||
Utils::Inreplace.inreplace formula.path do |s|
|
Utils::Inreplace.inreplace formula.path do |s|
|
||||||
if T.must(s.inreplace_string.split(/^ test do\b/, 2).first).scan(inreplace_regex).length > 1
|
if s.inreplace_string.split(/^ test do\b/, 2).fetch(0).scan(inreplace_regex).length > 1
|
||||||
odie "Unable to update resource blocks for \"#{formula.name}\" automatically. Please update them manually."
|
odie "Unable to update resource blocks for \"#{formula.name}\" automatically. Please update them manually."
|
||||||
end
|
end
|
||||||
s.sub! inreplace_regex, resource_section
|
s.sub! inreplace_regex, resource_section
|
||||||
|
Loading…
x
Reference in New Issue
Block a user