We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regexp literals that contain [^:] confuse the RedundantRegexpEscape cop into thinking that later backslashes are redundant.
[^:]
Rubocop should not identify any offenses in the example below. It should recognize that the backslashes are meaningful in context.
Rubocop reports that backslashes are redundant even though they are not.
$ cat test.rb # These 2 have different results, so the backslash # before the dot is not redundant puts /[^:]+./.match?('ab') puts /[^:]+\./.match?('ab') # These 2 have different results, so the backslashes # before the opening and closing parentheses are not redundant puts /[^:]\(u\)/.match?(':(u)') puts /[^:](u)/.match?(':(u)') $ ruby test.rb true false false true $ rubocop --only Style/RedundantRegexpEscape Inspecting 1 file C Offenses: test.rb:4:12: C: Style/RedundantRegexpEscape: Redundant escape inside regexp literal puts /[^:]+\./.match?('ab') ^^ test.rb:8:11: C: Style/RedundantRegexpEscape: Redundant escape inside regexp literal puts /[^:]\(u\)/.match?(':(u)') ^^ test.rb:8:14: C: Style/RedundantRegexpEscape: Redundant escape inside regexp literal puts /[^:]\(u\)/.match?(':(u)') ^^ 1 file inspected, 3 offenses detected
$ rubocop -V 0.88.0 (using Parser 2.7.1.4, rubocop-ast 0.3.0, running on ruby 2.5.0 x86_64-linux)
The text was updated successfully, but these errors were encountered:
This is fixed in master. Probably duplicates #8335
Sorry, something went wrong.
No branches or pull requests
Regexp literals that contain
[^:]
confuse the RedundantRegexpEscape cop into thinking that later backslashes are redundant.Expected behavior
Rubocop should not identify any offenses in the example below. It should recognize that the backslashes are meaningful in context.
Actual behavior
Rubocop reports that backslashes are redundant even though they are not.
Steps to reproduce the problem
RuboCop version
The text was updated successfully, but these errors were encountered: