lib/rubocop/cop/style/while_until_do.rb in rubocop-0.12.0 vs lib/rubocop/cop/style/while_until_do.rb in rubocop-0.13.0

- old
+ new

@@ -16,14 +16,12 @@ 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) + convention(node, :begin, + error_message(node.type)) end end end private @@ -32,10 +30,14 @@ format('Never use `do` with multi-line `%s`.', node_type) end def autocorrect_action(node) @corrections << lambda do |corrector| - corrector.remove(node.loc.begin) + condition_node, = *node + end_of_condition_range = condition_node.loc.expression.end + do_range = node.loc.begin + whitespaces_and_do_range = end_of_condition_range.join(do_range) + corrector.remove(whitespaces_and_do_range) end end end end end