class RuboCop::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/rubocop/cop/style/while_until_do.rb, line 17 def handle(node) return unless node.multiline? && node.do? add_offense(node, location: :begin, message: format(MSG, node.keyword)) end
on_until(node)
click to toggle source
# File lib/rubocop/cop/style/while_until_do.rb, line 13 def on_until(node) handle(node) end
on_while(node)
click to toggle source
# File lib/rubocop/cop/style/while_until_do.rb, line 9 def on_while(node) handle(node) end
Private Instance Methods
autocorrect(node)
click to toggle source
# File lib/rubocop/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