Sha256: 1bc3dc8decf1e4c998d190309e94ed7d7cd0953315b1045f9b2296214e64b6f6
Contents?: true
Size: 652 Bytes
Versions: 20
Compression:
Stored size: 652 Bytes
Contents
# encoding: utf-8 module RuboCop module Cop module Style # This cop checks for nested ternary op expressions. class NestedTernaryOperator < Cop MSG = 'Ternary operators must not be nested. Prefer `if`/`else` ' \ 'constructs instead.' def on_if(node) loc = node.loc # discard non-ternary ops return unless loc.respond_to?(:question) node.each_descendant(:if) do |nested_if_node| if nested_if_node.loc.respond_to?(:question) add_offense(nested_if_node, :expression) end end end end end end end
Version data entries
20 entries across 20 versions & 2 rubygems