Sha256: 97ac0b45d6a0dce27e0e7f3fcb14ac3597e44afecad15ae5a7eff393be343936
Contents?: true
Size: 850 Bytes
Versions: 1
Compression:
Stored size: 850 Bytes
Contents
# encoding: utf-8 module Rubocop module Cop module Style # Checks for uses of while with a negated condition. class NegatedWhile < Cop include NegativeConditional def on_while(node) check(node) end def error_message 'Favor `until` over `while` for negative conditions.' end private def autocorrect(node) @corrections << lambda do |corrector| condition, _body, _rest = *node # unwrap the negated portion of the condition (a send node) pos_condition, _method, = *condition corrector.replace(node.loc.keyword, 'until') corrector.replace(condition.loc.expression, pos_condition.loc.expression.source) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.20.0 | lib/rubocop/cop/style/negated_while.rb |