class RuboCop::Cop::Style::InfiniteLoop

def while_or_until(node)

def while_or_until(node)
  range = node.source_range
  # Not every `while true` and `until false` can be turned into a
  # `loop do` without further modification. The reason is that a
  # variable that's introduced inside a while/until loop is in scope
  # outside of that loop too, but a variable that's assigned for the
  # first time inside a block can not be accessed after the block. In
  # those more complicated cases we don't report an offense.
  return if @variables.any? do |var|
    assigned_inside_loop?(var, range) &&
    !assigned_before_loop?(var, range) &&
    referenced_after_loop?(var, range)
  end
  add_offense(node, location: :keyword)
end