class Rubocop::Cop::Style::NestedTernaryOperator

This cop checks for nested ternary op expressions.

Constants

MSG

Public Instance Methods

on_if(node) click to toggle source
Calls superclass method
# File lib/rubocop/cop/style/ternary_operator.rb, line 30
def on_if(node)
  loc = node.loc

  # discard non-ternary ops
  return unless loc.respond_to?(:question)

  node.children.each do |child|
    on_node(:if, child) do |c|
      if c.loc.respond_to?(:question)
        add_offence(:convention, c.loc.expression, MSG)
      end
    end
  end

  super
end