Parent

Methods

Files

Class/Module Index [+]

Quicksearch

RuboCop::Cop::Style::NestedTernaryOperator

This cop checks for nested ternary op expressions.

Constants

MSG

Public Instance Methods

on_if(node) click to toggle source
# File lib/rubocop/cop/style/nested_ternary_operator.rb, line 10
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|
      add_offense(c, :expression) if c.loc.respond_to?(:question)
    end
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.