lib/rubocop/cop/style/slicing_with_range.rb in rubocop-0.90.0 vs lib/rubocop/cop/style/slicing_with_range.rb in rubocop-0.91.0
- old
+ new
@@ -17,14 +17,15 @@
extend TargetRubyVersion
minimum_target_ruby_version 2.6
MSG = 'Prefer ary[n..] over ary[n..-1].'
+ RESTRICT_ON_SEND = %i[[]].freeze
def_node_matcher :range_till_minus_one?, '(irange !nil? (int -1))'
def on_send(node)
- return unless node.method?(:[]) && node.arguments.count == 1
+ return unless node.arguments.count == 1
return unless range_till_minus_one?(node.arguments.first)
add_offense(node.first_argument) do |corrector|
corrector.remove(node.first_argument.end)
end