rubocop-performance
rubocop-performance copied to clipboard
Performance/RedundantMatch: False positive
Steps to reproduce the problem
puts 'fox'.match(/(f)/) ? $1 : ''
puts $1 if 'cat'.match(/(c)/)
'rabbit'.match(/(r)/)
puts $1
exit unless 'squirrel'.match(/(s)/)
puts $1
Expected behavior
MatchData is successfully used in all examples, so should not get patted down by officer.
Actual behavior
4 x [Correctable] Performance/RedundantMatch: Use =~ in places where the MatchData returned by #match will not be used.
RuboCop version
ruby 2025-08-01 30a20bc16
rubocop 2025-10-18 f7f653f50
System Version: macOS 15.6 (24G84)
Model Identifier: MacBookAir10,1
Bömp! Still very much an issue. Just forgot it was disabled in .rubocop.yml pending resolution.
@5-hun: Thanks for looking into this one. What's holding #523 back from merging with master?