-
-
Notifications
You must be signed in to change notification settings - Fork 88
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Expected behavior
Expected the cop to report string.chars.last and autocorrect it to string[-1].
Actual behavior
The cop only corrects string.chars.first and does not report string.chars.last as an offense.
Steps to reproduce the problem
Create this rubocop.yml:
require: rubocop-performance
AllCops:
NewCops: enable
TargetRubyVersion: 3.0Create this test.rb file:
# frozen_string_literal: true
string = 'AZ'
p string.chars.first
p string.chars.lastRun rubocop or rubocop -A. The autocorrected output will be:
# frozen_string_literal: true
string = 'AZ'
p string[0]
p string.chars.lastRuboCop version
$ rubocop -V
1.39.0 (using Parser 3.1.2.1, rubocop-ast 1.23.0, running on ruby 3.1.0) [x86_64-linux]
- rubocop-performance 1.15.1
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working