Skip to content

Commit

Permalink
utils/shared_audits: audit deprecate/disable reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
bevanjkay committed Sep 30, 2024
1 parent 1c5bfa3 commit 53e8739
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Library/Homebrew/utils/shared_audits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,20 @@ def self.github_tag_from_url(url)
def self.gitlab_tag_from_url(url)
url[%r{^https://gitlab\.com/(?:\w[\w.-]*/){2,}-/archive/([^/]+)/}, 1]
end

sig { params(formula_or_cask: T.any(Formula, Cask::Cask)).returns(T.nilable(String)) }
def self.check_deprecate_disable_reason(formula_or_cask)
return if !formula_or_cask.deprecated? && !formula_or_cask.disabled?

reason = formula_or_cask.deprecated? ? formula_or_cask.deprecation_reason : formula_or_cask.disable_reason
return unless reason.is_a?(Symbol)

reasons = if formula_or_cask.is_a?(Formula)
DeprecateDisable::FORMULA_DEPRECATE_DISABLE_REASONS
else
DeprecateDisable::CASK_DEPRECATE_DISABLE_REASONS
end

"#{reason} is not a valid deprecate! or disable! reason" unless reasons.include?(reason)
end
end

0 comments on commit 53e8739

Please sign in to comment.