You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Style/RedundantRegexpEscape cop should not flag or fix escaped characters when they are being used as delimiters in a %r type regexp.
Actual behavior
The Style/RedundantRegexpEscape cop flags and fixes escaped characters when they are being used as delimiters in a %r type regexp. This causes a Syntax Error under several ruby versions.
Steps to reproduce the problem
Take this regexp matching for / or } characters:
%r{[/\}]}
Currently the cop will register this as an offense, and if run with autocorrect creates a syntax error.
$ rubocop test_file.rb -a --only Style/RedundantRegexpEscape
Inspecting 1 file
E
Offenses:
test_file.rb:1:1: E: Lint/Syntax: premature end of char-class: /[\//
(Using Ruby 2.6 parser; configure using TargetRubyVersion parameter, under AllCops)
%r{[/}]}
^^^^^^
test_file.rb:1:6: C: [Corrected] Style/RedundantRegexpEscape: Redundant escape inside regexp literal
%r{[/\}]}
^^
1 file inspected, 2 offenses detected, 1 offense corrected
Keep in mind that this applies for any delimiter, whether it be braces { } or other less common delimiters.
Expected behavior
The
Style/RedundantRegexpEscape
cop should not flag or fix escaped characters when they are being used as delimiters in a%r
type regexp.Actual behavior
The
Style/RedundantRegexpEscape
cop flags and fixes escaped characters when they are being used as delimiters in a%r
type regexp. This causes a Syntax Error under several ruby versions.Steps to reproduce the problem
Take this regexp matching for
/
or}
characters:%r{[/\}]}
Currently the cop will register this as an offense, and if run with autocorrect creates a syntax error.
Keep in mind that this applies for any delimiter, whether it be braces
{ }
or other less common delimiters.RuboCop version
The text was updated successfully, but these errors were encountered: