Skip to content

Commit

Permalink
rubocops/cask: fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
bevanjkay committed Feb 5, 2024
1 parent 2b60576 commit 60914a3
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Library/Homebrew/rubocops/cask/shared_filelist_glob.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ class SharedFilelistGlob < Base
extend AutoCorrector

def on_send(node)
return unless node.method_name == :zap
return if node.method_name != :zap

node.each_descendant(:pair).each do |pair|
symbols = pair.children.select(&:sym_type?).map(&:value)
next unless symbols.include?(:trash)

pair.each_descendant(:array).each do |array|

regex = /sfl\d"$/
message = "Use a glob (*) instead of a specific version (ie. sfl2) for trashing Shared File List paths"

array.children.each do |item|
next unless item.source.match?(regex)
next unless item.source.match?(regex)

corrected_item = item.source.sub(/sfl\d"$/, "sfl*\"")
corrected_item = item.source.sub(/sfl\d"$/, "sfl*\"")

add_offense(item, message: "Use a glob (*) instead of a specific version (ie. sfl2) for trashing Shared File List paths") do |corrector|
add_offense(item,
message: message) do |corrector|
corrector.replace(item, corrected_item)
end
end
Expand Down

0 comments on commit 60914a3

Please sign in to comment.