Ignore zap trash stanzas with interpolation

- Interpolating the version into a path is a common pattern, but the interpolations
  trip up the alphabetization autocorrect quite spectacularly, so let's
  ignore them (for now?).
This commit is contained in:
Issy Long 2023-12-21 20:21:45 +00:00
parent 73b3ace77c
commit f4754baa00
No known key found for this signature in database
GPG Key ID: 8247C390DADC67D4
2 changed files with 14 additions and 1 deletions

View File

@ -18,7 +18,7 @@ module RuboCop
end
end
array.each_descendant(:str).each_cons(2) do |first, second|
array.children.reject(&:dstr_type?).each_cons(2) do |first, second|
next if first.source.downcase < second.source.downcase
add_offense(second, message: "The `zap trash` paths should be in alphabetical order") do |corrector|

View File

@ -56,4 +56,17 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do
end
CASK
end
it "ignores zap trash paths that have interpolation" do
expect_no_offenses(<<~CASK)
cask "foo" do
url "https://example.com/foo.zip"
zap trash: [
"~/Library/Application Support/Foo",
"~/Library/Application Support/Bar\#{version.major}",
]
end
CASK
end
end