Skip to content

Style/RedundantRegexpEscape not run when NewCops: enable #14435

@forthrin

Description

@forthrin

By all signs, Style/RedundantRegexpEscape should be enabled by default, but for some reason it does not run on NewCops: enable. Is this a bug, or some implicit logic that is not obvious to the user

Steps to reproduce the problem

$ cat > rubocop.yml
AllCops:
  NewCops: enable
^D
$ cat > a.rb
/[\.-]/
^D
$ rubocop --show-cops Style/RedundantRegexpEscape
  Description: Checks for redundant escapes in Regexps.
  Enabled: true
  VersionAdded: '0.85'
$ rubocop -c rubocop.yml a.rb
1 file inspected, no offenses detected
$ cat > rubocop.yml
AllCops:
  NewCops: disable
^D
$ rubocop -c rubocop.yml a.rb
a.rb:1:2: C: [Correctable] Style/RedundantRegexpEscape: Redundant escape inside regexp literal
/\-/
 ^^

RuboCop version

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions