class RuboCop::Cop::Lint::RequireRangeParentheses


42)
(1..
# good
(1..42)
# good
1..42
# good
42
(1..)
# good - It’s incompatible, but your intentions when using endless range may be:
42
1..
# bad - Represents β€˜(1..42)`, not endless range.
@example
β€”-
end
do_something
when 42..
case condition
β€”-
[source,ruby]

So, this cop does not provide autocorrection because it is left to user.
NOTE: The following is maybe intended for `(42..)`. But, compatible is `42..do_something`.
at a line break.
Checks that a range literal is enclosed in parentheses when the end of the range is

def on_irange(node)

def on_irange(node)
  return if node.parent&.begin_type?
  return unless node.begin && node.end
  return if same_line?(node.begin, node.end)
  message = format(MSG, range: "#{node.begin.source}#{node.loc.operator.source}")
  add_offense(node, message: message)
end