Method: RuboCop::Cop::Style::WhileUntilDo#on_while

Defined in:
lib/rubocop/cop/style/while_until_do.rb

#on_while(node) ⇒ Object Also known as: on_until



34
35
36
37
38
39
40
41
42
# File 'lib/rubocop/cop/style/while_until_do.rb', line 34

def on_while(node)
  return unless node.multiline? && node.do?

  add_offense(node.loc.begin, message: format(MSG, keyword: node.keyword)) do |corrector|
    do_range = node.condition.source_range.end.join(node.loc.begin)

    corrector.remove(do_range)
  end
end