1
- # typed: true # rubocop:todo Sorbet/StrictSigil
1
+ # typed: strict
2
2
# frozen_string_literal: true
3
3
4
4
# Helper module for handling `disable!` and `deprecate!`.
5
5
# @api internal
6
6
module DeprecateDisable
7
7
module_function
8
8
9
- FORMULA_DEPRECATE_DISABLE_REASONS = {
9
+ FORMULA_DEPRECATE_DISABLE_REASONS = T . let ( {
10
10
does_not_build : "does not build" ,
11
11
no_license : "has no license" ,
12
12
repo_archived : "has an archived upstream repository" ,
@@ -19,27 +19,29 @@ module DeprecateDisable
19
19
"a different checksum than the current one. " \
20
20
"Upstream's repository might have been compromised. " \
21
21
"We can re-package this once upstream has confirmed that they retagged their release" ,
22
- } . freeze
22
+ } . freeze , T :: Hash [ Symbol , String ] )
23
23
24
- CASK_DEPRECATE_DISABLE_REASONS = {
24
+ CASK_DEPRECATE_DISABLE_REASONS = T . let ( {
25
25
discontinued : "is discontinued upstream" ,
26
26
moved_to_mas : "is now exclusively distributed on the Mac App Store" ,
27
27
no_longer_available : "is no longer available upstream" ,
28
28
no_longer_meets_criteria : "no longer meets the criteria for acceptable casks" ,
29
29
unmaintained : "is not maintained upstream" ,
30
30
unsigned : "is unsigned or does not meet signature requirements" ,
31
- } . freeze
31
+ } . freeze , T :: Hash [ Symbol , String ] )
32
32
33
33
# One year when << or >> to Date.today.
34
34
REMOVE_DISABLED_TIME_WINDOW = 12
35
- REMOVE_DISABLED_BEFORE = ( Date . today << REMOVE_DISABLED_TIME_WINDOW ) . freeze
35
+ REMOVE_DISABLED_BEFORE = T . let ( ( Date . today << REMOVE_DISABLED_TIME_WINDOW ) . freeze , Date )
36
36
37
+ sig { params ( formula_or_cask : T . any ( Formula , Cask ::Cask ) ) . returns ( T . nilable ( Symbol ) ) }
37
38
def type ( formula_or_cask )
38
39
return :deprecated if formula_or_cask . deprecated?
39
40
40
41
:disabled if formula_or_cask . disabled?
41
42
end
42
43
44
+ sig { params ( formula_or_cask : T . any ( Formula , Cask ::Cask ) ) . returns ( T . nilable ( String ) ) }
43
45
def message ( formula_or_cask )
44
46
return if type ( formula_or_cask ) . blank?
45
47
@@ -92,9 +94,12 @@ def message(formula_or_cask)
92
94
message
93
95
end
94
96
97
+ sig { params ( string : T . nilable ( String ) , type : Symbol ) . returns ( T . nilable ( T . any ( String , Symbol ) ) ) }
95
98
def to_reason_string_or_symbol ( string , type :)
96
- if ( type == :formula && FORMULA_DEPRECATE_DISABLE_REASONS . key? ( string &.to_sym ) ) ||
97
- ( type == :cask && CASK_DEPRECATE_DISABLE_REASONS . key? ( string &.to_sym ) )
99
+ return if string . nil?
100
+
101
+ if ( type == :formula && FORMULA_DEPRECATE_DISABLE_REASONS . key? ( string . to_sym ) ) ||
102
+ ( type == :cask && CASK_DEPRECATE_DISABLE_REASONS . key? ( string . to_sym ) )
98
103
return string . to_sym
99
104
end
100
105
0 commit comments