File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ class UninstallMethodsOrder < Base
1313
1414 MSG = T . let ( "`%<method>s` method out of order" , String )
1515
16+ # These keys are ignored when checking method order.
17+ # Mirrors AbstractUninstall::UPGRADE_METADATA_KEYS.
18+ UPGRADE_METADATA_KEYS = T . let (
19+ [ :quit_on_upgrade , :signal_on_upgrade ] . freeze ,
20+ T ::Array [ Symbol ] ,
21+ )
22+
1623 sig { params ( node : AST ::SendNode ) . void }
1724 def on_send ( node )
1825 return unless [ :zap , :uninstall ] . include? ( node . method_name )
@@ -21,6 +28,12 @@ def on_send(node)
2128 return if hash_node . nil? || ( !hash_node . is_a? ( AST ::Node ) && !hash_node . hash_type? )
2229
2330 method_nodes = hash_node . pairs . map ( &:key )
31+
32+ method_nodes = method_nodes . reject do |method |
33+ name = method . children . first
34+ UPGRADE_METADATA_KEYS . include? ( name )
35+ end
36+
2437 expected_order = method_nodes . sort_by { |method | method_order_index ( method ) }
2538 comments = processed_source . comments
2639
Original file line number Diff line number Diff line change 7878 end
7979 CASK
8080 end
81+
82+ it "ignores opt-in boolean keys such as quit_on_upgrade and signal_on_upgrade" do
83+ expect_no_offenses ( <<~CASK )
84+ cask "foo" do
85+ url "https://example.com/foo.zip"
86+
87+ uninstall quit: "com.example.foo",
88+ quit_on_upgrade: true,
89+ signal: ["TERM", "com.example.foo"],
90+ signal_on_upgrade: true,
91+ script: {
92+ executable: "/usr/local/bin/foo",
93+ sudo: false,
94+ },
95+ pkgutil: "org.foo.bar",
96+ delete: [
97+ "/usr/local/bin/foo",
98+ "/usr/local/bin/foobar",
99+ ]
100+ end
101+ CASK
102+ end
81103 end
82104
83105 context "with a single method" do
You can’t perform that action at this time.
0 commit comments