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 12, 2024
1 parent ad03691 commit f4b9658
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
10 changes: 5 additions & 5 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 Expand Up @@ -298,7 +295,10 @@ def self.try_new(ref, warn: false)
return if Homebrew::EnvConfig.no_install_from_api?
return unless ref.is_a?(String)
return unless (token = ref[HOMEBREW_DEFAULT_TAP_CASK_REGEX, :token])
return if !Homebrew::API::Cask.all_casks.key?(token) && !Homebrew::API::Cask.all_renames.key?(token)
if !Homebrew::API::Cask.all_casks.key?(token) &&
!Homebrew::API::Cask.all_renames.key?(token)
return
end

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

Expand Down
11 changes: 5 additions & 6 deletions Library/Homebrew/formulary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,9 @@ 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))
return unless (name = ref[HOMEBREW_TAP_FORMULA_REGEX, :name])

alias_name = T.cast(match[:name], String)
alias_name = 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,16 +853,15 @@ 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 (match = ref.match(HOMEBREW_DEFAULT_TAP_FORMULA_REGEX))

name = alias_name = T.cast(match[:name], String)
return unless (name = ref[HOMEBREW_DEFAULT_TAP_FORMULA_REGEX, :name])
if !Homebrew::API::Formula.all_formulae.key?(name) &&
!Homebrew::API::Formula.all_aliases.key?(name) &&
!Homebrew::API::Formula.all_renames.key?(name)
return
end

alias_name = name

ref = "#{CoreTap.instance}/#{name}"

name, tap, type = Formulary.tap_formula_name_type(ref, warn: warn)
Expand Down

0 comments on commit f4b9658

Please sign in to comment.