Class: RuboCop::Cop::Homebrew::SimpleInterpolation Private

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

Keep branching and multi-step computations outside interpolation.

Examples:

# bad
"Queue: #{queue || fallback}"

# good
selected_queue = queue || fallback
"Queue: #{selected_queue}"

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.

"Move this expression outside the interpolation."

Constants included from SimpleExpression

RuboCop::Cop::Homebrew::SimpleExpression::MAX_VALUE_PARTS

Instance Method Summary collapse

Methods included from SimpleExpression

#integer_literal?, #literal_or_reference?, #static_expression?

Instance Method Details

#on_begin(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:



24
25
26
27
28
29
# File 'rubocops/simple_interpolation.rb', line 24

def on_begin(node)
  return unless node.loc_is?(:begin, '#{')
  return if node.children.empty?

  add_offense(node) if excessive_logic?(node)
end