Sha256: bf4de0fe0ac606a71e9144deba0cdde30342811c8c6d10e6e25d3a2368da9bed
Contents?: true
Size: 637 Bytes
Versions: 4
Compression:
Stored size: 637 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.children.each do |child| on_node(:if, child) do |c| add_offense(c, :expression) if c.loc.respond_to?(:question) end end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems