Skip to content

Performance/RedundantMatch: False positive #509

@forthrin

Description

@forthrin

Expected behavior

MatchData is used, so this shouldn't be reported.

$ ruby a.rb
o

Actual behavior

a.rb:1:12: C: [Correctable] Performance/RedundantMatch: Use =~ in places where the MatchData returned by #match will not be used.
puts $~ if 'foxes'.match(/[aeiouy]/)
           ^^^^^^^^^^^^^^^^^^^^^^^^^

Steps to reproduce the problem

puts $~ if 'foxes'.match(/[aeiouy]/)`

RuboCop version

rubocop-performance (1.25.0)
ruby      2025-08-01 30a20bc16
rubocop   2025-08-11 c595cf6e2
System Version: macOS 15.6 (24G84)
Model Identifier: MacBookAir10,1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions