Class: RuboCop::Cop::Homebrew::ShellCommandStub Private

Inherits:
Base
  • Object
show all
Defined in:
rubocops/shell_command_stub.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.

Constant Summary collapse

MSG =

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.

"Shell command stubs must have a `.sh` counterpart."
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.

[:include].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 (AST::SendNode)


12
13
14
15
16
17
18
19
20
# File 'rubocops/shell_command_stub.rb', line 12

def on_send(node)
  return if node.first_argument&.const_name != "ShellCommand"

  stub_path = Pathname.new(processed_source.file_path)
  sh_cmd_path = Pathname.new("#{stub_path.dirname}/#{stub_path.basename(".rb")}.sh")
  return if sh_cmd_path.exist?

  add_offense(node)
end