Ignore non-zap trash methods

This commit is contained in:
Issy Long 2023-12-22 00:41:56 +00:00
parent b9f13fc35d
commit fb124f92ed
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
2 changed files with 15 additions and 0 deletions

View File

@ -14,6 +14,8 @@ module RuboCop
return if node.method_name != :zap
node.each_descendant(:pair).each do |pair|
next if pair.children.select(&:sym_type?).map(&:value) != [:trash]
pair.each_descendant(:array).each do |array|
if array.children.length == 1
add_offense(array, message: SINGLE_MSG) do |corrector|

View File

@ -77,4 +77,17 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do
end
CASK
end
it "ignores `zap` methods other than `trash`" do
expect_no_offenses(<<~CASK)
cask "foo" do
url "https://example.com/foo.zip"
zap delete: [
"~/Library/Application Support/Foo",
"~/Library/Application Support/Bar",
]
end
CASK
end
end