class RubbyCop::Cop::Style::WhileUntilDo
Checks for uses of `do` in multi-line `while/until` statements.
Constants
- MSG
Public Instance Methods
handle(node)
click to toggle source
# File lib/rubbycop/cop/style/while_until_do.rb, line 18 def handle(node) return unless node.multiline? && node.do? add_offense(node, :begin, format(MSG, node.keyword)) end
on_until(node)
click to toggle source
# File lib/rubbycop/cop/style/while_until_do.rb, line 14 def on_until(node) handle(node) end
on_while(node)
click to toggle source
# File lib/rubbycop/cop/style/while_until_do.rb, line 10 def on_while(node) handle(node) end
Private Instance Methods
autocorrect(node)
click to toggle source
# File lib/rubbycop/cop/style/while_until_do.rb, line 26 def autocorrect(node) do_range = node.condition.source_range.end.join(node.loc.begin) lambda do |corrector| corrector.remove(do_range) end end