class RuboCop::Cop::Style::NegatedWhile

Checks for uses of while with a negated condition.

def autocorrect(node)

def autocorrect(node)
  lambda do |corrector|
    condition, _body, _rest = *node
    # Look inside parentheses around the condition, if any.
    condition, = *condition while condition.begin_type?
    # Unwrap the negated portion of the condition (a send node).
    pos_condition, _method, = *condition
    corrector.replace(
      node.loc.keyword,
      node.while_type? ? 'until' : 'while'
    )
    corrector.replace(condition.source_range, pos_condition.source)
  end
end

def message(node)

def message(node)
  if node.while_type?
    format(MSG, 'until', 'while')
  else
    format(MSG, 'while', 'until')
  end
end

def on_until(node)

def on_until(node)
  check_negative_conditional(node)
end

def on_while(node)

def on_while(node)
  check_negative_conditional(node)
end