Class: RuboCop::Cop::Cask::SharedFilelistGlob Private
- Extended by:
- AutoCorrector
- Defined in:
- rubocops/cask/shared_filelist_glob.rb
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Instance Method Summary collapse
- #on_send(node) ⇒ Object private
Instance Method Details
#on_send(node) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'rubocops/cask/shared_filelist_glob.rb', line 10 def on_send(node) 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"$/ = "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) corrected_item = item.source.sub(/sfl\d"$/, "sfl*\"") add_offense(item, message:) do |corrector| corrector.replace(item, corrected_item) end end end end end |