Sha256: b5f41696332e41460d3ca1dbf9cc30e8048e22d565cb98228f3c7e127958d645
Contents?: true
Size: 601 Bytes
Versions: 5
Compression:
Stored size: 601 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Style # This cop looks for *unless* expressions with *else* clauses. class UnlessElse < Cop MSG = 'Never use unless with else. Rewrite these with the ' + 'positive case first.' def on_if(node) loc = node.loc # discard ternary ops and modifier if/unless nodes return unless loc.respond_to?(:keyword) && loc.respond_to?(:else) if loc.keyword.is?('unless') && loc.else convention(node, :expression) end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems