From 1d549c4815d220ddd02370d03ee8e821f6652893 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 8 Feb 2024 20:06:34 +0100 Subject: [PATCH 1/3] Avoid `T.must`. --- Library/Homebrew/formula.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 5533a1cd6d..8ba65e1e9e 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -540,8 +540,8 @@ class Formula # Old names for the formula. sig { returns(T::Array[String]) } def oldnames - @oldnames ||= if tap - T.must(tap).formula_oldnames.fetch(name, []) + @oldnames ||= if (tap = self.tap) + tap.formula_oldnames.fetch(name, []) else [] end @@ -550,8 +550,8 @@ class Formula # All aliases for the formula. sig { returns(T::Array[String]) } def aliases - @aliases ||= if tap - T.must(tap).alias_reverse_table[full_name].to_a.map do |a| + @aliases ||= if (tap = self.tap) + tap.alias_reverse_table[full_name].to_a.map do |a| a.split("/").last end else From a20d95b1b5fcb269096f5bb0b8210385db31861a Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 9 Feb 2024 16:51:35 +0100 Subject: [PATCH 2/3] Simplify conditionals. --- Library/Homebrew/formula.rb | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 8ba65e1e9e..3160e4968a 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -540,23 +540,13 @@ class Formula # Old names for the formula. sig { returns(T::Array[String]) } def oldnames - @oldnames ||= if (tap = self.tap) - tap.formula_oldnames.fetch(name, []) - else - [] - end + @oldnames ||= tap&.formula_oldnames&.dig(name) || [] end # All aliases for the formula. sig { returns(T::Array[String]) } def aliases - @aliases ||= if (tap = self.tap) - tap.alias_reverse_table[full_name].to_a.map do |a| - a.split("/").last - end - else - [] - end + @aliases ||= tap&.alias_reverse_table&.dig(full_name)&.map { |a| a.split("/").last } || [] end # The {Resource}s for the currently active {SoftwareSpec}. From 5cc1ddc5c5de22bed45faa392b6eb6a3549d4e99 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Fri, 9 Feb 2024 17:03:01 +0100 Subject: [PATCH 3/3] Use numbered block parameter. Co-authored-by: Douglas Eichelberger <697964+dduugg@users.noreply.github.com> --- Library/Homebrew/formula.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 3160e4968a..aa8a5393c3 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -546,7 +546,7 @@ class Formula # All aliases for the formula. sig { returns(T::Array[String]) } def aliases - @aliases ||= tap&.alias_reverse_table&.dig(full_name)&.map { |a| a.split("/").last } || [] + @aliases ||= tap&.alias_reverse_table&.dig(full_name)&.map { _1.split("/").last } || [] end # The {Resource}s for the currently active {SoftwareSpec}.