Expected behavior
Use [0, 2] instead of .chars[0, 2].join if anything.
Actual behavior
a.rb:1:7: C: [Correctable] Performance/RedundantStringChars: Use [0] instead of chars[0, 2].
'foo'.chars[0, 2].join
^^^^^^^^^^^
Following the advice as given will produce invalid code.
(Issue was found while trying different techniques to make printf indent correctly for multibyte chars.)
Steps to reproduce the problem
RuboCop version
ruby 2025-08-01 30a20bc16
rubocop 2025-10-04 a08091813
System Version: macOS 15.6 (24G84)
Model Identifier: MacBookAir10,1
Expected behavior
Use [0, 2] instead of .chars[0, 2].joinif anything.Actual behavior
a.rb:1:7: C: [Correctable] Performance/RedundantStringChars: Use [0] instead of chars[0, 2]. 'foo'.chars[0, 2].join ^^^^^^^^^^^Following the advice as given will produce invalid code.
(Issue was found while trying different techniques to make
printfindent correctly for multibyte chars.)Steps to reproduce the problem
RuboCop version