class RuboCop::Cop::Style::NestedTernaryOperator
This cop checks for nested ternary op expressions.
@example
# bad a ? (b ? b1 : b2) : a2 # good if a b ? b1 : b2 else a2 end
Constants
- MSG
Public Instance Methods
on_if(node)
click to toggle source
# File lib/rubocop/cop/style/nested_ternary_operator.rb, line 22 def on_if(node) return unless node.ternary? node.each_descendant(:if).select(&:ternary?).each do |nested_ternary| add_offense(nested_ternary) end end