class Rubocop::Cop::Style::WhileUntilDo
Checks for uses of ‘do` in multi-line `while/until` statements.
def autocorrect_action(node)
def autocorrect_action(node) remove(node.loc.begin) end
def error_message(node_type)
def error_message(node_type) format('Never use `do` with multi-line `%s`.', node_type) end
def handle(node)
def handle(node) length = node.loc.expression.source.lines.to_a.size if length > 1 if node.loc.begin && node.loc.begin.is?('do') add_offence(:convention, node.loc.begin, error_message(node.type)) do_autocorrect(node) end end end
def on_until(node)
def on_until(node) handle(node) super end
def on_while(node)
def on_while(node) handle(node) super end