lib/rubocop/cop/lint/ambiguous_range.rb in rubocop-1.66.1 vs lib/rubocop/cop/lint/ambiguous_range.rb in rubocop-1.67.0
- old
+ new
@@ -55,10 +55,11 @@
# a.foo..b.bar
#
# # good
# (a.foo)..(b.bar)
class AmbiguousRange < Base
+ include RationalLiteral
extend AutoCorrector
MSG = 'Wrap complex range boundaries with parentheses to avoid ambiguity.'
def on_irange(node)
@@ -77,15 +78,17 @@
def each_boundary(range)
yield range.begin if range.begin
yield range.end if range.end
end
+ # rubocop:disable Metrics/CyclomaticComplexity
def acceptable?(node)
node.begin_type? ||
- node.literal? ||
+ node.literal? || rational_literal?(node) ||
node.variable? || node.const_type? || node.self_type? ||
(node.call_type? && acceptable_call?(node))
end
+ # rubocop:enable Metrics/CyclomaticComplexity
def acceptable_call?(node)
return true if node.unary_operation?
# Require parentheses when making a method call on a literal