From 8cf58e36e6479ffa0f56608856573e90269dfb77 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Tue, 19 Dec 2023 23:35:16 +0000 Subject: [PATCH 01/19] Add a new RuboCop for alphabetizing `zap trash` array elements - Part of issue 16323. - Previously this was being done manually by Cask maintainers. - While we're here, enforce that the `zap trash` path is not in `[]` if it only contains a single element. - This is buggy on actual Casks, hence the draft PR. --- .../rubocops/cask/array_alphabetization.rb | 38 ++++++++++++ Library/Homebrew/rubocops/rubocop-cask.rb | 1 + .../cask/array_alphabetization_spec.rb | 59 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 Library/Homebrew/rubocops/cask/array_alphabetization.rb create mode 100644 Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb new file mode 100644 index 0000000000..394a97f8cd --- /dev/null +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -0,0 +1,38 @@ +# typed: true +# frozen_string_literal: true + +module RuboCop + module Cop + module Cask + class ArrayAlphabetization < Base + extend AutoCorrector + + def on_send(node) + return if node.method_name != :zap + + node.each_descendant(:pair).each do |pair| + pair.each_descendant(:array).each do |array| + if array.children.length == 1 + add_offense(array, message: "Remove the `[]` around a single `zap trash` path") do |corrector| + corrector.replace(array.source_range, array.children.first.source) + end + end + + array.each_descendant(:str).each_cons(2) do |first, second| + next if first.source < second.source + + add_offense(second, message: "The `zap trash` paths should be in alphabetical order") do |corrector| + corrector.insert_before(first.source_range, second.source) + corrector.insert_before(second.source_range, first.source) + # Using `corrector.replace` here trips the clobbering detection. + corrector.remove(first.source_range) + corrector.remove(second.source_range) + end + end + end + end + end + end + end + end +end diff --git a/Library/Homebrew/rubocops/rubocop-cask.rb b/Library/Homebrew/rubocops/rubocop-cask.rb index a5ee744b8d..f174ba76e9 100644 --- a/Library/Homebrew/rubocops/rubocop-cask.rb +++ b/Library/Homebrew/rubocops/rubocop-cask.rb @@ -12,6 +12,7 @@ require_relative "cask/extend/node" require_relative "cask/mixin/cask_help" require_relative "cask/mixin/on_homepage_stanza" require_relative "cask/mixin/on_url_stanza" +require_relative "cask/array_alphabetization" require_relative "cask/desc" require_relative "cask/homepage_url_trailing_slash" require_relative "cask/no_overrides" diff --git a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb new file mode 100644 index 0000000000..fddcf0ac2a --- /dev/null +++ b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb @@ -0,0 +1,59 @@ + +# frozen_string_literal: true + +require "rubocops/rubocop-cask" + +describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do + it "reports an offense when a single `zap trash` path is specified in an array" do + source = <<~CASK + cask "foo" do + url "https://example.com/foo.zip" + + zap trash: ["~/Library/Application Support/Foo"] + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Remove the `[]` around a single `zap trash` path + end + CASK + + expect_offense(source) + expect_correction(<<~CASK) + cask "foo" do + url "https://example.com/foo.zip" + + zap trash: "~/Library/Application Support/Foo" + end + CASK + end + + it "reports an offense when the `zap trash` paths are not in alphabetical order" do + source = <<~CASK + cask "foo" do + url "https://example.com/foo.zip" + + zap trash: [ + "/Library/Application Support/Foo", + "/Library/Application Support/Baz", + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The `zap trash` paths should be in alphabetical order + "~/Library/Application Support/Foo", + "~/.dotfiles/thing", + ^^^^^^^^^^^^^^^^^^^ The `zap trash` paths should be in alphabetical order + "~/Library/Application Support/Bar", + ] + end + CASK + + expect_offense(source) + expect_correction(<<~CASK) + cask "foo" do + url "https://example.com/foo.zip" + + zap trash: [ + "/Library/Application Support/Baz", + "/Library/Application Support/Foo", + "~/.dotfiles/thing", + "~/Library/Application Support/Bar", + "~/Library/Application Support/Foo", + ] + end + CASK + end +end From 73b3ace77cf5fcbfde00a4992e3c45e8d2ba1be8 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Thu, 21 Dec 2023 01:25:18 +0000 Subject: [PATCH 02/19] Apparently `N` is alphabetically before `c`; downcase the comparison --- Library/Homebrew/rubocops/cask/array_alphabetization.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index 394a97f8cd..b4c0bc50fe 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -19,7 +19,7 @@ module RuboCop end array.each_descendant(:str).each_cons(2) do |first, second| - next if first.source < second.source + next if first.source.downcase < second.source.downcase add_offense(second, message: "The `zap trash` paths should be in alphabetical order") do |corrector| corrector.insert_before(first.source_range, second.source) From f4754baa0070adf191f56bc0685668ddc9734907 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Thu, 21 Dec 2023 20:21:45 +0000 Subject: [PATCH 03/19] 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?). --- .../Homebrew/rubocops/cask/array_alphabetization.rb | 2 +- .../rubocops/cask/array_alphabetization_spec.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index b4c0bc50fe..3ee5dbbf28 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -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| diff --git a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb index fddcf0ac2a..cd84115fe8 100644 --- a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb +++ b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb @@ -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 From f34accfcdefb7d85ce72304dad67e6ba0c8c53c0 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Fri, 22 Dec 2023 00:20:02 +0000 Subject: [PATCH 04/19] Make the test `expect_offense` calls consistent with other tests --- .../test/rubocops/cask/array_alphabetization_spec.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb index cd84115fe8..42e67d6ce5 100644 --- a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb +++ b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb @@ -1,11 +1,10 @@ - # frozen_string_literal: true require "rubocops/rubocop-cask" describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do it "reports an offense when a single `zap trash` path is specified in an array" do - source = <<~CASK + expect_offense(<<~CASK) cask "foo" do url "https://example.com/foo.zip" @@ -14,7 +13,6 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do end CASK - expect_offense(source) expect_correction(<<~CASK) cask "foo" do url "https://example.com/foo.zip" @@ -25,7 +23,7 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do end it "reports an offense when the `zap trash` paths are not in alphabetical order" do - source = <<~CASK + expect_offense(<<~CASK) cask "foo" do url "https://example.com/foo.zip" @@ -41,7 +39,6 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do end CASK - expect_offense(source) expect_correction(<<~CASK) cask "foo" do url "https://example.com/foo.zip" From b9f13fc35da5ecefe7a2a47ce64d0f6b58b5ce93 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Fri, 22 Dec 2023 00:22:33 +0000 Subject: [PATCH 05/19] Better detection and replacement of non-alphabetized arrays - Use `sort_by` to sort the array, rather than comparing each element to the next. - This doesn't error with complaints about clobbering at all when run on `homebrew/cask`, hurray. And it also handles interpolations correctly, rather than ignoring them. Co-authored-by: Bevan Kay --- .../rubocops/cask/array_alphabetization.rb | 20 ++++++++++--------- .../cask/array_alphabetization_spec.rb | 19 ++++++++++++++---- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index 3ee5dbbf28..ff268be6ce 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -7,26 +7,28 @@ module RuboCop class ArrayAlphabetization < Base extend AutoCorrector + SINGLE_MSG = "Remove the `[]` around a single `zap trash` path".freeze + NON_ALPHABETICAL_MSG = "The `zap trash` paths should be in alphabetical order".freeze + def on_send(node) return if node.method_name != :zap node.each_descendant(:pair).each do |pair| pair.each_descendant(:array).each do |array| if array.children.length == 1 - add_offense(array, message: "Remove the `[]` around a single `zap trash` path") do |corrector| + add_offense(array, message: SINGLE_MSG) do |corrector| corrector.replace(array.source_range, array.children.first.source) end end - array.children.reject(&:dstr_type?).each_cons(2) do |first, second| - next if first.source.downcase < second.source.downcase + next if array.children.length <= 1 - add_offense(second, message: "The `zap trash` paths should be in alphabetical order") do |corrector| - corrector.insert_before(first.source_range, second.source) - corrector.insert_before(second.source_range, first.source) - # Using `corrector.replace` here trips the clobbering detection. - corrector.remove(first.source_range) - corrector.remove(second.source_range) + sorted_array = array.children.sort_by { |child| child.source.downcase } + next if sorted_array.map(&:source) == array.children.map(&:source) + + add_offense(array, message: NON_ALPHABETICAL_MSG) do |corrector| + array.children.each_with_index do |child, index| + corrector.replace(child.source_range, sorted_array[index].source) end end end diff --git a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb index 42e67d6ce5..2d932750b7 100644 --- a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb +++ b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb @@ -28,12 +28,11 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do url "https://example.com/foo.zip" zap trash: [ + ^ The `zap trash` paths should be in alphabetical order "/Library/Application Support/Foo", "/Library/Application Support/Baz", - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The `zap trash` paths should be in alphabetical order "~/Library/Application Support/Foo", "~/.dotfiles/thing", - ^^^^^^^^^^^^^^^^^^^ The `zap trash` paths should be in alphabetical order "~/Library/Application Support/Bar", ] end @@ -54,16 +53,28 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do CASK end - it "ignores zap trash paths that have interpolation" do - expect_no_offenses(<<~CASK) + it "autocorrects alphabetization in zap trash paths with interpolation" do + expect_offense(<<~CASK) cask "foo" do url "https://example.com/foo.zip" zap trash: [ + ^ The `zap trash` paths should be in alphabetical order "~/Library/Application Support/Foo", "~/Library/Application Support/Bar\#{version.major}", ] end CASK + + expect_correction(<<~CASK) + cask "foo" do + url "https://example.com/foo.zip" + + zap trash: [ + "~/Library/Application Support/Bar\#{version.major}", + "~/Library/Application Support/Foo", + ] + end + CASK end end From fb124f92edc20ceb127888513ce62b21f0363512 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Fri, 22 Dec 2023 00:41:56 +0000 Subject: [PATCH 06/19] Ignore non-`zap trash` methods --- .../Homebrew/rubocops/cask/array_alphabetization.rb | 2 ++ .../rubocops/cask/array_alphabetization_spec.rb | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index ff268be6ce..335a5e22c2 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -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| diff --git a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb index 2d932750b7..73f79a2e6e 100644 --- a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb +++ b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb @@ -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 From 9070f6d8292cf3a76f896db6f796e13eedfd5a58 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Tue, 2 Jan 2024 23:31:13 +0000 Subject: [PATCH 07/19] Check `uninstall` too, avoiding arrays containing commands --- .../rubocops/cask/array_alphabetization.rb | 15 +++---- .../cask/array_alphabetization_spec.rb | 39 +++++++++++++++++-- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index 335a5e22c2..2b0766b47b 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -7,18 +7,19 @@ module RuboCop class ArrayAlphabetization < Base extend AutoCorrector - SINGLE_MSG = "Remove the `[]` around a single `zap trash` path".freeze - NON_ALPHABETICAL_MSG = "The `zap trash` paths should be in alphabetical order".freeze - def on_send(node) - return if node.method_name != :zap + return unless [:zap, :uninstall].include?(name = node.method_name) node.each_descendant(:pair).each do |pair| - next if pair.children.select(&:sym_type?).map(&:value) != [:trash] + symbols = pair.children.select { |child| child.sym_type? }.map(&:value) + # For `zap`s, we only care about `trash` arrays. + next if name == :zap && !symbols.include?(:trash) + # Don't order `uninstall` arrays that contain commands. + next if name == :uninstall && (symbols & [:signal, :script, :early_script]).any? pair.each_descendant(:array).each do |array| if array.children.length == 1 - add_offense(array, message: SINGLE_MSG) do |corrector| + add_offense(array, message: "Avoid single-element arrays by removing the []") do |corrector| corrector.replace(array.source_range, array.children.first.source) end end @@ -28,7 +29,7 @@ module RuboCop sorted_array = array.children.sort_by { |child| child.source.downcase } next if sorted_array.map(&:source) == array.children.map(&:source) - add_offense(array, message: NON_ALPHABETICAL_MSG) do |corrector| + add_offense(array, message: "The array elements should be ordered alphabetically") do |corrector| array.children.each_with_index do |child, index| corrector.replace(child.source_range, sorted_array[index].source) end diff --git a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb index 73f79a2e6e..d576ef9573 100644 --- a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb +++ b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb @@ -9,7 +9,7 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do url "https://example.com/foo.zip" zap trash: ["~/Library/Application Support/Foo"] - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Remove the `[]` around a single `zap trash` path + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid single-element arrays by removing the [] end CASK @@ -28,7 +28,7 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do url "https://example.com/foo.zip" zap trash: [ - ^ The `zap trash` paths should be in alphabetical order + ^ The array elements should be ordered alphabetically "/Library/Application Support/Foo", "/Library/Application Support/Baz", "~/Library/Application Support/Foo", @@ -59,7 +59,7 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do url "https://example.com/foo.zip" zap trash: [ - ^ The `zap trash` paths should be in alphabetical order + ^ The array elements should be ordered alphabetically "~/Library/Application Support/Foo", "~/Library/Application Support/Bar\#{version.major}", ] @@ -90,4 +90,37 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do end CASK end + + it "autocorrects alphabetization in `uninstall` methods" do + expect_offense(<<~CASK) + cask "foo" do + url "https://example.com/foo.zip" + + uninstall pkgutil: [ + ^ The array elements should be ordered alphabetically + "something", + "other", + ], + script: [ + "ordered", + "differently", + ] + end + CASK + + expect_correction(<<~CASK) + cask "foo" do + url "https://example.com/foo.zip" + + uninstall pkgutil: [ + "other", + "something", + ], + script: [ + "ordered", + "differently", + ] + end + CASK + end end From 6a1cb62b423ef4b352491e0207eea1b0d2426283 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sun, 14 Jan 2024 20:55:22 +0000 Subject: [PATCH 08/19] Appease RuboCop --- Library/Homebrew/rubocops/cask/array_alphabetization.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index 2b0766b47b..2db41d7e9f 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -11,7 +11,7 @@ module RuboCop return unless [:zap, :uninstall].include?(name = node.method_name) node.each_descendant(:pair).each do |pair| - symbols = pair.children.select { |child| child.sym_type? }.map(&:value) + symbols = pair.children.select(&:sym_type?).map(&:value) # For `zap`s, we only care about `trash` arrays. next if name == :zap && !symbols.include?(:trash) # Don't order `uninstall` arrays that contain commands. From 338e30ff9b9c6ffa11fe020afbef7ef4e021c554 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sun, 14 Jan 2024 20:55:51 +0000 Subject: [PATCH 09/19] There are more arrays that contain non-alphabetizeable commands --- Library/Homebrew/rubocops/cask/array_alphabetization.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index 2db41d7e9f..59120319d8 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -15,7 +15,7 @@ module RuboCop # For `zap`s, we only care about `trash` arrays. next if name == :zap && !symbols.include?(:trash) # Don't order `uninstall` arrays that contain commands. - next if name == :uninstall && (symbols & [:signal, :script, :early_script]).any? + next if name == :uninstall && (symbols & [:signal, :script, :early_script, :args, :input]).any? pair.each_descendant(:array).each do |array| if array.children.length == 1 From 2c9e6e425b97d274f18397d7e4e7f5ceb2737174 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sun, 14 Jan 2024 20:57:08 +0000 Subject: [PATCH 10/19] Autofix `Cask/ArrayAlphabetization` offenses in test fixtures --- .../Homebrew/test/support/fixtures/cask/Casks/everything.rb | 2 +- .../test/support/fixtures/cask/Casks/with-installable.rb | 4 ++-- .../test/support/fixtures/cask/Casks/with-uninstall-delete.rb | 4 ++-- .../test/support/fixtures/cask/Casks/with-uninstall-trash.rb | 4 ++-- .../test/support/fixtures/cask/Casks/with-zap-trash.rb | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/everything.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/everything.rb index b253c3d787..1f0cfe08f5 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/everything.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/everything.rb @@ -32,7 +32,7 @@ cask "everything" do } uninstall launchctl: "com.every.thing.agent", - delete: ["/Library/EverythingHelperTools"], + delete: "/Library/EverythingHelperTools", kext: "com.every.thing.driver", signal: [ ["TERM", "com.every.thing.controller#{version.major}"], diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb index fe7cd83008..d6f8ad75b6 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-installable.rb @@ -12,10 +12,10 @@ cask "with-installable" do login_item: "Fancy", delete: [ "#{TEST_TMPDIR}/absolute_path", - "~/path_with_tilde", "#{TEST_TMPDIR}/glob_path*", - "impermissible/relative/path", "/another/impermissible/../relative/path", + "impermissible/relative/path", + "~/path_with_tilde", ], rmdir: "#{TEST_TMPDIR}/empty_directory_path" end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb index f40775872e..d38206c3c1 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-delete.rb @@ -9,9 +9,9 @@ cask "with-uninstall-delete" do uninstall delete: [ "#{TEST_TMPDIR}/absolute_path", - "~/path_with_tilde", "#{TEST_TMPDIR}/glob_path*", - "impermissible/relative/path", "/another/impermissible/../relative/path", + "impermissible/relative/path", + "~/path_with_tilde", ] end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb index 4f3fac0313..9fa108133b 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-uninstall-trash.rb @@ -9,9 +9,9 @@ cask "with-uninstall-trash" do uninstall trash: [ "#{TEST_TMPDIR}/absolute_path", - "~/path_with_tilde", "#{TEST_TMPDIR}/glob_path*", - "impermissible/relative/path", "/another/impermissible/../relative/path", + "impermissible/relative/path", + "~/path_with_tilde", ] end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb index 11651a4f2f..4cd1c15011 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-trash.rb @@ -9,9 +9,9 @@ cask "with-zap-trash" do zap trash: [ "#{TEST_TMPDIR}/absolute_path", - "~/path_with_tilde", "#{TEST_TMPDIR}/glob_path*", - "impermissible/relative/path", "/another/impermissible/../relative/path", + "impermissible/relative/path", + "~/path_with_tilde", ] end From e4b4af4c456397db3ae4a67272f38134a0075d7c Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sun, 14 Jan 2024 21:32:50 +0000 Subject: [PATCH 11/19] Add a failing test for comments moving with the alphabetization --- .../cask/array_alphabetization_spec.rb | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb index d576ef9573..3f2a7c6623 100644 --- a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb +++ b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb @@ -123,4 +123,46 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do end CASK end + + it "ignores `uninstall` methods with commands" do + expect_no_offenses(<<~CASK) + cask "foo" do + url "https://example.com/foo.zip" + + uninstall script: { + args: ["--mode=something", "--another-mode"], + executable: "thing", + } + end + CASK + end + + focus it "moves comments when autocorrecting" do + expect_offense(<<~CASK) + cask "foo" do + url "https://example.com/foo.zip" + + zap trash: [ + ^ The array elements should be ordered alphabetically + # overall comment, shouldn't move + "~/Library/Application Support/Foo", + "~/Library/Application Support/Bar", + "~/Library/Application Support/Baz", # in-line comment + ] + end + CASK + + expect_correction(<<~CASK) + cask "foo" do + url "https://example.com/foo.zip" + + zap trash: [ + # overall comment, shouldn't move + "~/Library/Application Support/Bar", + "~/Library/Application Support/Baz", # in-line comment + "~/Library/Application Support/Foo", + ] + end + CASK + end end From dae9b0cd534d8643c44a8f6ddd111120a3d21166 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Thu, 18 Jan 2024 12:53:23 +0000 Subject: [PATCH 12/19] very wip and bad comment handling --- .../rubocops/cask/array_alphabetization.rb | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index 59120319d8..03d48a41c4 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -26,17 +26,40 @@ module RuboCop next if array.children.length <= 1 - sorted_array = array.children.sort_by { |child| child.source.downcase } - next if sorted_array.map(&:source) == array.children.map(&:source) + comments = find_inline_comments(array.source) + array_with_comments = array.children.dup + array.children.map(&:source).each_with_index do |child, index| + comment = comments.find { |c| c.include?(child) } + next unless comment + + p comment.strip + # Add the comment to the main array. + array_with_comments[index] = comment.strip + end + + sorted_array = array_with_comments.sort_by { |child| child.to_s.downcase } + next if sorted_array == array_with_comments add_offense(array, message: "The array elements should be ordered alphabetically") do |corrector| array.children.each_with_index do |child, index| - corrector.replace(child.source_range, sorted_array[index].source) + p sorted_array[index] + corrector.replace(child.source_range, sorted_array[index]) end end end end end + + def find_inline_comments(source) + comments = [] + source.each_line do |line| + # Comments are naively detected by looking for lines that include a `#` surrounded by spaces. + comments << line if line.include?(" # ") + end + + # Remove lines that are only comments, we don't want to move those. + comments.reject { |comment| comment.strip.start_with?("# ") } + end end end end From 779f1bba7d9d14567a051e7dda8f20175e63e001 Mon Sep 17 00:00:00 2001 From: "Bevan J. Kay" Date: Sat, 20 Jan 2024 00:03:03 +0000 Subject: [PATCH 13/19] Move comments in tandem with the lines they belong to --- .../rubocops/cask/array_alphabetization.rb | 49 ++++++++++--------- .../cask/array_alphabetization_spec.rb | 6 +-- 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index 03d48a41c4..45db8e4136 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -26,39 +26,42 @@ module RuboCop next if array.children.length <= 1 - comments = find_inline_comments(array.source) - array_with_comments = array.children.dup - array.children.map(&:source).each_with_index do |child, index| - comment = comments.find { |c| c.include?(child) } - next unless comment + sorted_array = sort_array(array.source.split("\n")).join("\n") - p comment.strip - # Add the comment to the main array. - array_with_comments[index] = comment.strip - end - - sorted_array = array_with_comments.sort_by { |child| child.to_s.downcase } - next if sorted_array == array_with_comments + next if array.source == sorted_array add_offense(array, message: "The array elements should be ordered alphabetically") do |corrector| - array.children.each_with_index do |child, index| - p sorted_array[index] - corrector.replace(child.source_range, sorted_array[index]) - end + corrector.replace(array.source_range, sorted_array) end end end end - def find_inline_comments(source) - comments = [] - source.each_line do |line| - # Comments are naively detected by looking for lines that include a `#` surrounded by spaces. - comments << line if line.include?(" # ") + def sort_array(source) + # Combine each comment with the line below it so that they remain connected to the line they comment + combined_source = source.each_with_index.map do |line, index| + if line.strip.start_with?('#') && index < source.length - 1 + "#{line}\n#{source[index + 1]}" + elsif source[index - 1]&.strip&.start_with?('#') + nil + else + line + end + end.compact + + # Separate the lines into those that should be sorted and those that should not + # ie. skip the opening and closing brackets of the array + to_sort, to_keep = combined_source.partition { |line| !line.include?('[') && !line.include?(']') } + + # Sort the lines that should be sorted + to_sort.sort! do |a, b| + a_non_comment = a.split("\n").reject { |line| line.strip.start_with?('#') }.first + b_non_comment = b.split("\n").reject { |line| line.strip.start_with?('#') }.first + a_non_comment.downcase <=> b_non_comment.downcase end - # Remove lines that are only comments, we don't want to move those. - comments.reject { |comment| comment.strip.start_with?("# ") } + # Merge the sorted lines and the unsorted lines, preserving the original positions of the unsorted lines + combined_source.map { |line| to_keep.include?(line) ? line : to_sort.shift } end end end diff --git a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb index 3f2a7c6623..9eba528ed8 100644 --- a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb +++ b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb @@ -137,14 +137,14 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do CASK end - focus it "moves comments when autocorrecting" do + it "moves comments when autocorrecting" do expect_offense(<<~CASK) cask "foo" do url "https://example.com/foo.zip" zap trash: [ ^ The array elements should be ordered alphabetically - # overall comment, shouldn't move + # comment related to foo "~/Library/Application Support/Foo", "~/Library/Application Support/Bar", "~/Library/Application Support/Baz", # in-line comment @@ -157,9 +157,9 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do url "https://example.com/foo.zip" zap trash: [ - # overall comment, shouldn't move "~/Library/Application Support/Bar", "~/Library/Application Support/Baz", # in-line comment + # comment related to foo "~/Library/Application Support/Foo", ] end From e9bcb6400054c9a9e62815116ec07e2afc6d56b0 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sat, 20 Jan 2024 00:35:40 +0000 Subject: [PATCH 14/19] Double quotes not single --- .../Homebrew/rubocops/cask/array_alphabetization.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index 45db8e4136..95ad1ee29a 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -40,9 +40,9 @@ module RuboCop def sort_array(source) # Combine each comment with the line below it so that they remain connected to the line they comment combined_source = source.each_with_index.map do |line, index| - if line.strip.start_with?('#') && index < source.length - 1 + if line.strip.start_with?("#") && index < source.length - 1 "#{line}\n#{source[index + 1]}" - elsif source[index - 1]&.strip&.start_with?('#') + elsif source[index - 1]&.strip&.start_with?("#") nil else line @@ -51,12 +51,12 @@ module RuboCop # Separate the lines into those that should be sorted and those that should not # ie. skip the opening and closing brackets of the array - to_sort, to_keep = combined_source.partition { |line| !line.include?('[') && !line.include?(']') } + to_sort, to_keep = combined_source.partition { |line| !line.include?("[") && !line.include?("]") } # Sort the lines that should be sorted to_sort.sort! do |a, b| - a_non_comment = a.split("\n").reject { |line| line.strip.start_with?('#') }.first - b_non_comment = b.split("\n").reject { |line| line.strip.start_with?('#') }.first + a_non_comment = a.split("\n").reject { |line| line.strip.start_with?("#") }.first + b_non_comment = b.split("\n").reject { |line| line.strip.start_with?("#") }.first a_non_comment.downcase <=> b_non_comment.downcase end From eec7a96fbed77b5d9fcb0dda298745343e3b6522 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sat, 20 Jan 2024 00:38:21 +0000 Subject: [PATCH 15/19] Use Ruby 3.1's `intersect\?` method --- Library/Homebrew/rubocops/cask/array_alphabetization.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index 95ad1ee29a..97e5be079f 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -15,7 +15,7 @@ module RuboCop # For `zap`s, we only care about `trash` arrays. next if name == :zap && !symbols.include?(:trash) # Don't order `uninstall` arrays that contain commands. - next if name == :uninstall && (symbols & [:signal, :script, :early_script, :args, :input]).any? + next if name == :uninstall && symbols.intersect?([:signal, :script, :early_script, :args, :input]) pair.each_descendant(:array).each do |array| if array.children.length == 1 From 8910d5a479a92c73d37e4ea65d4a345a3bf0f678 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sun, 21 Jan 2024 01:32:01 +0000 Subject: [PATCH 16/19] Remove the single-element array in `everything.json` used for Cask tests ``` 1) Cask::Cask#to_h when loaded from cask file returns expected hash Failure/Error: expect(JSON.pretty_generate(hash)).to eq(expected_json) Diff: @@ -28,9 +28,7 @@ "uninstall": [ { "launchctl": "com.every.thing.agent", - "delete": [ - "/Library/EverythingHelperTools" - ], + "delete": "/Library/EverythingHelperTools", "kext": "com.every.thing.driver", "signal": [ [ @@ -103,7 +101,7 @@ ], "ruby_source_path": "Casks/everything.rb", "ruby_source_checksum": { - "sha256": "b2707d1952f02c3fa566b7ad2a707a847a959d36f51d3dee642dbe5deec12f27" + "sha256": "0c4af571cce1632fc6a3dcf3e75ba82a3283077ef12399428192c26f9d6f779b" } } # ./test/cask/cask_spec.rb:225:in `block (4 levels) in ' # ./test/support/helper/spec/shared_context/homebrew_cask.rb:53:in `block (2 levels) in ' ``` --- Library/Homebrew/test/support/fixtures/cask/everything.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/test/support/fixtures/cask/everything.json b/Library/Homebrew/test/support/fixtures/cask/everything.json index f29f88a4fa..9f8243f9ae 100644 --- a/Library/Homebrew/test/support/fixtures/cask/everything.json +++ b/Library/Homebrew/test/support/fixtures/cask/everything.json @@ -28,9 +28,7 @@ "uninstall": [ { "launchctl": "com.every.thing.agent", - "delete": [ - "/Library/EverythingHelperTools" - ], + "delete": "/Library/EverythingHelperTools", "kext": "com.every.thing.driver", "signal": [ [ @@ -103,6 +101,6 @@ ], "ruby_source_path": "Casks/everything.rb", "ruby_source_checksum": { - "sha256": "b2707d1952f02c3fa566b7ad2a707a847a959d36f51d3dee642dbe5deec12f27" + "sha256": "0c4af571cce1632fc6a3dcf3e75ba82a3283077ef12399428192c26f9d6f779b" } } From 458844af44d5a85488629b398bca161cd292d574 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sun, 21 Jan 2024 12:42:22 +0000 Subject: [PATCH 17/19] Move multi-line comments with the code they're 'attached' to Co-authored-by: Bevan J. Kay --- .../rubocops/cask/array_alphabetization.rb | 19 +++++++++++-------- .../cask/array_alphabetization_spec.rb | 6 ++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index 97e5be079f..49734bcc08 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -38,15 +38,10 @@ module RuboCop end def sort_array(source) - # Combine each comment with the line below it so that they remain connected to the line they comment + # Combine each comment with the line(s) below so that they remain in the same relative location combined_source = source.each_with_index.map do |line, index| - if line.strip.start_with?("#") && index < source.length - 1 - "#{line}\n#{source[index + 1]}" - elsif source[index - 1]&.strip&.start_with?("#") - nil - else - line - end + next if line.strip.start_with?("#") + next recursively_find_comments(source, index, line) end.compact # Separate the lines into those that should be sorted and those that should not @@ -63,6 +58,14 @@ module RuboCop # Merge the sorted lines and the unsorted lines, preserving the original positions of the unsorted lines combined_source.map { |line| to_keep.include?(line) ? line : to_sort.shift } end + + def recursively_find_comments(source, index, line) + if source[index - 1].strip.start_with?("#") + return recursively_find_comments(source, index - 1, "#{source[index - 1]}\n#{line}") + end + + line + end end end end diff --git a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb index 9eba528ed8..ad5a2b98a1 100644 --- a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb +++ b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb @@ -146,6 +146,9 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do ^ The array elements should be ordered alphabetically # comment related to foo "~/Library/Application Support/Foo", + # a really long comment related to Zoo + # and the Zoo comment continues + "~/Library/Application Support/Zoo", "~/Library/Application Support/Bar", "~/Library/Application Support/Baz", # in-line comment ] @@ -161,6 +164,9 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do "~/Library/Application Support/Baz", # in-line comment # comment related to foo "~/Library/Application Support/Foo", + # a really long comment related to Zoo + # and the Zoo comment continues + "~/Library/Application Support/Zoo", ] end CASK From d5f9eef1b546acfb2b81f9cfc6e98bc5b4ae6ce8 Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sun, 21 Jan 2024 12:47:33 +0000 Subject: [PATCH 18/19] Empty line after guard clause, gah --- Library/Homebrew/rubocops/cask/array_alphabetization.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index 49734bcc08..de52dddb9c 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -41,6 +41,7 @@ module RuboCop # Combine each comment with the line(s) below so that they remain in the same relative location combined_source = source.each_with_index.map do |line, index| next if line.strip.start_with?("#") + next recursively_find_comments(source, index, line) end.compact From 693a27d48bcd204053d88471a89fcd06b3f44b4a Mon Sep 17 00:00:00 2001 From: Issy Long Date: Sun, 21 Jan 2024 19:21:40 +0000 Subject: [PATCH 19/19] Treat `zap` and `uninstall` the same - Since `zap` can have more than just `trash`. --- .../rubocops/cask/array_alphabetization.rb | 7 ++---- .../cask/array_alphabetization_spec.rb | 24 ++++++++----------- .../fixtures/cask/Casks/with-zap-delete.rb | 4 ++-- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/Library/Homebrew/rubocops/cask/array_alphabetization.rb b/Library/Homebrew/rubocops/cask/array_alphabetization.rb index de52dddb9c..d6ca7f3ca3 100644 --- a/Library/Homebrew/rubocops/cask/array_alphabetization.rb +++ b/Library/Homebrew/rubocops/cask/array_alphabetization.rb @@ -8,14 +8,11 @@ module RuboCop extend AutoCorrector def on_send(node) - return unless [:zap, :uninstall].include?(name = node.method_name) + return unless [:zap, :uninstall].include?(node.method_name) node.each_descendant(:pair).each do |pair| symbols = pair.children.select(&:sym_type?).map(&:value) - # For `zap`s, we only care about `trash` arrays. - next if name == :zap && !symbols.include?(:trash) - # Don't order `uninstall` arrays that contain commands. - next if name == :uninstall && symbols.intersect?([:signal, :script, :early_script, :args, :input]) + next if symbols.intersect?([:signal, :script, :early_script, :args, :input]) pair.each_descendant(:array).each do |array| if array.children.length == 1 diff --git a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb index ad5a2b98a1..da981e714b 100644 --- a/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb +++ b/Library/Homebrew/test/rubocops/cask/array_alphabetization_spec.rb @@ -22,7 +22,7 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do CASK end - it "reports an offense when the `zap trash` paths are not in alphabetical order" do + it "reports an offense when the `zap` stanza paths are not in alphabetical order" do expect_offense(<<~CASK) cask "foo" do url "https://example.com/foo.zip" @@ -34,6 +34,11 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do "~/Library/Application Support/Foo", "~/.dotfiles/thing", "~/Library/Application Support/Bar", + ], + rmdir: [ + ^ The array elements should be ordered alphabetically + "/Applications/foo/nested/blah", + "/Applications/foo/", ] end CASK @@ -48,6 +53,10 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do "~/.dotfiles/thing", "~/Library/Application Support/Bar", "~/Library/Application Support/Foo", + ], + rmdir: [ + "/Applications/foo/", + "/Applications/foo/nested/blah", ] end CASK @@ -78,19 +87,6 @@ describe RuboCop::Cop::Cask::ArrayAlphabetization, :config do 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 - it "autocorrects alphabetization in `uninstall` methods" do expect_offense(<<~CASK) cask "foo" do diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb index 706ca7a2f1..1e7f57ea1f 100644 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb +++ b/Library/Homebrew/test/support/fixtures/cask/Casks/with-zap-delete.rb @@ -9,9 +9,9 @@ cask "with-zap-delete" do zap delete: [ "#{TEST_TMPDIR}/absolute_path", - "~/path_with_tilde", "#{TEST_TMPDIR}/glob_path*", - "impermissible/relative/path", "/another/impermissible/../relative/path", + "impermissible/relative/path", + "~/path_with_tilde", ] end