Sha256: b62915290132020115a1bd84508a4e8836906b0ab50efec43f6be61c2e2c2680
Contents?: true
Size: 586 Bytes
Versions: 9
Compression:
Stored size: 586 Bytes
Contents
# encoding: utf-8 module RuboCop module Cop module Style # This cop checks for multi-line ternary op expressions. class MultilineTernaryOperator < Cop MSG = 'Avoid multi-line ?: (the ternary operator);' \ ' use `if`/`unless` instead.' def on_if(node) _condition, _if_branch, else_branch = *node loc = node.loc # discard non-ternary ops return unless loc.respond_to?(:question) add_offense(node, :expression) if loc.line != else_branch.loc.line end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems