Class: RuboCop::Cop::Cask::DisallowedPatterns Private

Inherits:
Base
  • Object
show all
Defined in:
rubocops/cask/disallowed_patterns.rb

Overview

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.

This cop checks uninstall/zap for patterns that shouldn't be used.

Constant Summary collapse

DISALLOWED_PATTERNS =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

T.let([
  {
    pattern: "com.install4j.*",
    reason:  "install4j distributions must include the unique ID number, e.g. " \
             "`com.install4j.1234-5678-9012-3456`, to prevent matching other applications.",
  },
].freeze, T::Array[{ pattern: String, reason: String }])
RESTRICT_ON_SEND =

This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.

[:uninstall, :zap].freeze

Instance Method Summary collapse

Instance Method Details

#on_send(node) ⇒ void

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.

This method returns an undefined value.

Parameters:

  • node (RuboCop::AST::SendNode)


20
21
22
23
24
25
26
27
28
# File 'rubocops/cask/disallowed_patterns.rb', line 20

def on_send(node)
  node.each_descendant(:str) do |str|
    DISALLOWED_PATTERNS.each do |disallowed|
      next unless str.source.include?(disallowed.fetch(:pattern))

      add_offense(str, message: disallowed.fetch(:reason))
    end
  end
end