diff --git a/Library/Homebrew/cmd/untap.rb b/Library/Homebrew/cmd/untap.rb index 17c5c11af6..fdac754001 100644 --- a/Library/Homebrew/cmd/untap.rb +++ b/Library/Homebrew/cmd/untap.rb @@ -49,7 +49,7 @@ module Homebrew sig { params(tap: Tap).returns(T::Array[Formula]) } def installed_formulae_for(tap:) 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 Formulary.factory(formula_name) @@ -68,7 +68,7 @@ module Homebrew sig { params(tap: Tap).returns(T::Array[Cask::Cask]) } def installed_casks_for(tap:) 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::CaskLoader.load(cask_token) diff --git a/Library/Homebrew/cmd/update-report.rb b/Library/Homebrew/cmd/update-report.rb index 70ec32074c..13bed07d10 100644 --- a/Library/Homebrew/cmd/update-report.rb +++ b/Library/Homebrew/cmd/update-report.rb @@ -500,7 +500,7 @@ class Reporter case status when "A", "D" 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] @report[T.must(status).to_sym] << full_name unless new_tap when "M" @@ -614,7 +614,7 @@ class Reporter sig { void } def migrate_tap_migration (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] next if new_tap_name.nil? # skip if not in tap_migrations list. @@ -901,7 +901,7 @@ class ReporterHub true end 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)) puts "#{cask_token}: #{desc}" else @@ -924,7 +924,7 @@ class ReporterHub return if Homebrew::SimulateSystem.simulating_or_running_on_linux? 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) end diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 4c4235d38d..e76fa53e3f 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -1332,7 +1332,7 @@ module Formulary if (possible_alias = tap.alias_table[alias_table_key].presence) # FIXME: Remove the need to split the name and instead make # the alias table only contain short names. - name = T.must(possible_alias.split("/").last) + name = possible_alias.split("/").fetch(-1) type = :alias elsif (new_name = tap.formula_renames[name].presence) old_name = tap.core_tap? ? name : tapped_name