Sha256: 50c0c94e8c995309fd1ad85f09d6bd8c727305af6fd1a0e61522c75ef2f32308
Contents?: true
Size: 633 Bytes
Versions: 2
Compression:
Stored size: 633 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.19.1 | lib/rubocop/cop/style/nested_ternary_operator.rb |
rubocop-0.19.0 | lib/rubocop/cop/style/nested_ternary_operator.rb |