Sha256: acba0607203016a3185e864319976630d7b2a89084dac97ced0a2523ec16cd4b
Contents?: true
Size: 606 Bytes
Versions: 3
Compression:
Stored size: 606 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 add_offence(node, :expression) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.18.1 | lib/rubocop/cop/style/unless_else.rb |
rubocop-0.18.0 | lib/rubocop/cop/style/unless_else.rb |
rubocop-0.17.0 | lib/rubocop/cop/style/unless_else.rb |