diff --git a/Library/Homebrew/aliases/aliases.rb b/Library/Homebrew/aliases/aliases.rb index b8aa064a4b..0b95596dea 100644 --- a/Library/Homebrew/aliases/aliases.rb +++ b/Library/Homebrew/aliases/aliases.rb @@ -43,7 +43,7 @@ module Homebrew next if !only.empty? && only.exclude?(name) lines.reject! { |line| line.start_with?("#") || line =~ /^\s*$/ } - first_line = T.must(lines.first) + first_line = lines.fetch(0) command = first_line.chomp command.sub!(/ \$\*$/, "") diff --git a/Library/Homebrew/cask/caskroom.rb b/Library/Homebrew/cask/caskroom.rb index 1b83d33feb..c0e88584fd 100644 --- a/Library/Homebrew/cask/caskroom.rb +++ b/Library/Homebrew/cask/caskroom.rb @@ -61,7 +61,7 @@ module Cask tokens.sort.filter_map do |token| CaskLoader.load_prefer_installed(token, config:, warn: false) rescue TapCaskAmbiguityError => e - T.must(e.loaders.first).load(config:) + e.loaders.fetch(0).load(config:) rescue # Don't blow up because of a single unavailable cask. nil diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb index 1c1e6634b0..47be13dd97 100644 --- a/Library/Homebrew/cmd/deps.rb +++ b/Library/Homebrew/cmd/deps.rb @@ -91,7 +91,7 @@ module Homebrew 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" - os, arch = T.must(args.os_arch_combinations.first) + os, arch = args.os_arch_combinations.fetch(0) eval_all = args.eval_all? Formulary.enable_factory_cache! diff --git a/Library/Homebrew/cmd/log.rb b/Library/Homebrew/cmd/log.rb index e76f131b87..9cb9e302de 100644 --- a/Library/Homebrew/cmd/log.rb +++ b/Library/Homebrew/cmd/log.rb @@ -44,7 +44,7 @@ module Homebrew if args.no_named? git_log(HOMEBREW_REPOSITORY) else - path = T.must(args.named.to_paths.first) + path = args.named.to_paths.fetch(0) tap = Tap.from_path(path) git_log path.dirname, path, tap end diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index d08fedd671..9f39c870b5 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -464,7 +464,7 @@ module Homebrew odie "`brew audit` failed for #{commit[:formula_name]}!" 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? "#{formula.name} #{new_formula_version}" diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb index 87f1f41ee0..e0e030192b 100644 --- a/Library/Homebrew/language/python.rb +++ b/Library/Homebrew/language/python.rb @@ -252,7 +252,7 @@ module Language raise FormulaUnknownPythonError, self if wanted.empty? raise FormulaAmbiguousPythonError, self if wanted.size > 1 - python = T.must(wanted.first) + python = wanted.fetch(0) python = "python3" if python == "python" end diff --git a/Library/Homebrew/postinstall.rb b/Library/Homebrew/postinstall.rb index f69d270de3..aaef3dd92b 100644 --- a/Library/Homebrew/postinstall.rb +++ b/Library/Homebrew/postinstall.rb @@ -24,7 +24,7 @@ begin 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? require "debrew" formula.extend(Debrew::Formula) diff --git a/Library/Homebrew/test.rb b/Library/Homebrew/test.rb index 1f2b1c8956..ee13b34453 100644 --- a/Library/Homebrew/test.rb +++ b/Library/Homebrew/test.rb @@ -36,7 +36,7 @@ begin raise "Cannot kill child processes without `pkill`, please install!" unless which("pkill") 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::FreePort) if args.debug? && !Homebrew::EnvConfig.disable_debrew? diff --git a/Library/Homebrew/unpack_strategy/tar.rb b/Library/Homebrew/unpack_strategy/tar.rb index ae3ff08cd2..65d5750847 100644 --- a/Library/Homebrew/unpack_strategy/tar.rb +++ b/Library/Homebrew/unpack_strategy/tar.rb @@ -59,7 +59,7 @@ module UnpackStrategy } def subextract(extractor, dir, verbose) extractor.new(path).extract(to: dir, verbose:) - T.must(dir.children.first) + dir.children.fetch(0) end end end diff --git a/Library/Homebrew/utils/analytics.rb b/Library/Homebrew/utils/analytics.rb index 5af6765cf8..d9136a168c 100644 --- a/Library/Homebrew/utils/analytics.rb +++ b/Library/Homebrew/utils/analytics.rb @@ -313,7 +313,7 @@ module Utils ) 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) (millions_match.captures.first.to_f * 1_000_000).to_i else diff --git a/Library/Homebrew/utils/cpan.rb b/Library/Homebrew/utils/cpan.rb index aefdbd89f1..3aad167042 100644 --- a/Library/Homebrew/utils/cpan.rb +++ b/Library/Homebrew/utils/cpan.rb @@ -180,7 +180,7 @@ module CPAN ohai "Updating resource blocks" unless silent 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." end s.sub! inreplace_regex, resource_section diff --git a/Library/Homebrew/utils/fork.rb b/Library/Homebrew/utils/fork.rb index 5da2621622..f76a679f27 100644 --- a/Library/Homebrew/utils/fork.rb +++ b/Library/Homebrew/utils/fork.rb @@ -109,7 +109,7 @@ module Utils raise Interrupt if $CHILD_STATUS.termsig == Signal.list["INT"] 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) end diff --git a/Library/Homebrew/utils/pypi.rb b/Library/Homebrew/utils/pypi.rb index ace69cab10..fcf8f839dd 100644 --- a/Library/Homebrew/utils/pypi.rb +++ b/Library/Homebrew/utils/pypi.rb @@ -441,7 +441,7 @@ module PyPI ohai "Updating resource blocks" unless silent 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." end s.sub! inreplace_regex, resource_section