Sha256: 2d54faaa53dbbc3234a42c09d2d596928f47516fdbe86d1258df68f97e5ea7fc
Contents?: true
Size: 548 Bytes
Versions: 6
Compression:
Stored size: 548 Bytes
Contents
# frozen_string_literal: true 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` or `else` ' \ 'constructs instead.'.freeze def on_if(node) return unless node.ternary? node.each_descendant(:if).select(&:ternary?).each do |nested_ternary| add_offense(nested_ternary, :expression) end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems