deprecate_disable: typed: strict
This commit is contained in:
parent
d09fb099a3
commit
21f35368eb
@ -134,11 +134,12 @@ on_request: true)
|
||||
raise
|
||||
end
|
||||
|
||||
sig { void }
|
||||
def check_deprecate_disable
|
||||
deprecate_disable_type = DeprecateDisable.type(@cask)
|
||||
return if deprecate_disable_type.nil?
|
||||
|
||||
message = DeprecateDisable.message(@cask)
|
||||
message = DeprecateDisable.message(@cask).to_s
|
||||
message_full = "#{@cask.token} has been #{message}"
|
||||
|
||||
case deprecate_disable_type
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Helper module for handling `disable!` and `deprecate!`.
|
||||
@ -6,7 +6,7 @@
|
||||
module DeprecateDisable
|
||||
module_function
|
||||
|
||||
FORMULA_DEPRECATE_DISABLE_REASONS = {
|
||||
FORMULA_DEPRECATE_DISABLE_REASONS = T.let({
|
||||
does_not_build: "does not build",
|
||||
no_license: "has no license",
|
||||
repo_archived: "has an archived upstream repository",
|
||||
@ -19,27 +19,29 @@ module DeprecateDisable
|
||||
"a different checksum than the current one. " \
|
||||
"Upstream's repository might have been compromised. " \
|
||||
"We can re-package this once upstream has confirmed that they retagged their release",
|
||||
}.freeze
|
||||
}.freeze, T::Hash[Symbol, String])
|
||||
|
||||
CASK_DEPRECATE_DISABLE_REASONS = {
|
||||
CASK_DEPRECATE_DISABLE_REASONS = T.let({
|
||||
discontinued: "is discontinued upstream",
|
||||
moved_to_mas: "is now exclusively distributed on the Mac App Store",
|
||||
no_longer_available: "is no longer available upstream",
|
||||
no_longer_meets_criteria: "no longer meets the criteria for acceptable casks",
|
||||
unmaintained: "is not maintained upstream",
|
||||
unsigned: "is unsigned or does not meet signature requirements",
|
||||
}.freeze
|
||||
}.freeze, T::Hash[Symbol, String])
|
||||
|
||||
# One year when << or >> to Date.today.
|
||||
REMOVE_DISABLED_TIME_WINDOW = 12
|
||||
REMOVE_DISABLED_BEFORE = (Date.today << REMOVE_DISABLED_TIME_WINDOW).freeze
|
||||
REMOVE_DISABLED_BEFORE = T.let((Date.today << REMOVE_DISABLED_TIME_WINDOW).freeze, Date)
|
||||
|
||||
sig { params(formula_or_cask: T.any(Formula, Cask::Cask)).returns(T.nilable(Symbol)) }
|
||||
def type(formula_or_cask)
|
||||
return :deprecated if formula_or_cask.deprecated?
|
||||
|
||||
:disabled if formula_or_cask.disabled?
|
||||
end
|
||||
|
||||
sig { params(formula_or_cask: T.any(Formula, Cask::Cask)).returns(T.nilable(String)) }
|
||||
def message(formula_or_cask)
|
||||
return if type(formula_or_cask).blank?
|
||||
|
||||
@ -92,9 +94,12 @@ module DeprecateDisable
|
||||
message
|
||||
end
|
||||
|
||||
sig { params(string: T.nilable(String), type: Symbol).returns(T.nilable(T.any(String, Symbol))) }
|
||||
def to_reason_string_or_symbol(string, type:)
|
||||
if (type == :formula && FORMULA_DEPRECATE_DISABLE_REASONS.key?(string&.to_sym)) ||
|
||||
(type == :cask && CASK_DEPRECATE_DISABLE_REASONS.key?(string&.to_sym))
|
||||
return if string.nil?
|
||||
|
||||
if (type == :formula && FORMULA_DEPRECATE_DISABLE_REASONS.key?(string.to_sym)) ||
|
||||
(type == :cask && CASK_DEPRECATE_DISABLE_REASONS.key?(string.to_sym))
|
||||
return string.to_sym
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user