Skip to content

Commit

Permalink
Avoid T.cast.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Feb 9, 2024
1 parent 45f5040 commit 059ab7f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
5 changes: 1 addition & 4 deletions Library/Homebrew/cask/cask_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,7 @@ class FromDefaultTapLoader < FromTapLoader
}
def self.try_new(ref, warn: false)
ref = ref.to_s

return unless (match = ref.match(HOMEBREW_DEFAULT_TAP_CASK_REGEX))

token = match[:token]
return unless (token = ref[HOMEBREW_DEFAULT_TAP_CASK_REGEX, :token])

ref = "#{CoreCaskTap.instance}/#{token}"

Expand Down
8 changes: 2 additions & 6 deletions Library/Homebrew/formulary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,7 @@ class FromTapLoader < FormulaLoader
}
def self.try_new(ref, from: T.unsafe(nil), warn: false)
ref = ref.to_s
return unless (match = ref.match(HOMEBREW_TAP_FORMULA_REGEX))

alias_name = T.cast(match[:name], String)
return unless (name = alias_name = ref[HOMEBREW_TAP_FORMULA_REGEX, :name])

name, tap, type = Formulary.tap_formula_name_type(ref, warn: warn)
path = Formulary.find_formula_in_tap(name, tap)
Expand Down Expand Up @@ -853,10 +851,8 @@ class FromAPILoader < FormulaLoader
def self.try_new(ref, from: T.unsafe(nil), warn: false)
return if Homebrew::EnvConfig.no_install_from_api?
return unless ref.is_a?(String)
return unless (name = alias_name = ref[HOMEBREW_DEFAULT_TAP_FORMULA_REGEX, :name])

return unless (match = ref.match(HOMEBREW_DEFAULT_TAP_FORMULA_REGEX))

name = alias_name = T.cast(match[:name], String)
if !Homebrew::API::Formula.all_formulae.key?(name) &&
!Homebrew::API::Formula.all_aliases.key?(name) &&
!Homebrew::API::Formula.all_renames.key?(name)
Expand Down

0 comments on commit 059ab7f

Please sign in to comment.