Class: RuboCop::Cop::Homebrew::InstallStepsSourceIndependence Private

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

Prevents structured install-step runners from depending on formula source, formula resources or direct downloads after a bottle is poured.

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.

"Install-step runners must use bottled files and API context " \
"without loading formula source or resources."
SOURCE_CONSTANTS =

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.

%w[Formula Formulary Resource].freeze

Instance Method Summary collapse

Instance Method Details

#on_const(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::ConstNode)


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

def on_const(node)
  return unless SOURCE_CONSTANTS.include?(node.const_name)

  parent = node.parent
  return if parent.is_a?(RuboCop::AST::SendNode) && parent.receiver == node

  add_offense(node)
end

#on_send(node) ⇒ void Also known as: on_csend

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)


15
16
17
# File 'rubocops/install_steps_source_independence.rb', line 15

def on_send(node)
  add_offense(node) if source_dependent?(node)
end