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
I believe #11152 introduced a false positive.
Given the regex
%r{ remote: (?:git@|git://|https://)(?<domain>[^/]+)[/:](?<slug>[\w\-._]+/[\w\-._]+)}
rubocop shouldn't complain about the redundancy of slashes in the <slug> capture, as removing them leads to a syntax error:
<slug>
unmatched range specifier in char-class: / remote: (?:git@|git:\/\/|https:\/\/)(?<domain>[^\/]+)[\/:](?<slug>[\w-._]+\/[\w-._]+)/
C: [Correctable] Style/RedundantRegexpEscape: Redundant escape inside regexp literal GIT_URI_REGEX = %r{ remote: (?:git@|git://|https://)(?<domain>[^/]+)[/:](?<slug>[\w\-._]+/[\w\-._]+)} ^^ C: [Correctable] Style/RedundantRegexpEscape: Redundant escape inside regexp literal GIT_URI_REGEX = %r{ remote: (?:git@|git://|https://)(?<domain>[^/]+)[/:](?<slug>[\w\-._]+/[\w\-._]+)} ^^
rubocop -V 1.39.0 (using Parser 3.1.2.1, rubocop-ast 1.23.0, running on ruby 3.1.2) [arm64-darwin21] - rubocop-performance 1.15.0 - rubocop-rspec 2.15.0
The text was updated successfully, but these errors were encountered:
I boiled the provided REGEX down to some simpler examples;
%r{[\w\-x]}
%r{[\w-x]}
%r{[x\-\w]}
%r{[x-\w]}
The same applies when replacing \w with any of the character classes;
\w
\s
\S
\d
\D
\W
Hope that helps when someone is able to write a spec and fix it 🤞 🙏
Sorry, something went wrong.
Style/RedundantRegexpEscape
\w\-\#
\w-\#
%r{...}
f0ff982
Merge pull request #11395 from si-lens/fix_redundant_regexp_escape_bug
6d37149
[Fix #11180] Fix `Style/RedundantRegexpEscape` bug when regexp provided within `%r{...}` literal
No branches or pull requests
I believe #11152 introduced a false positive.
Expected behavior
Given the regex
rubocop shouldn't complain about the redundancy of slashes in the
<slug>
capture, as removing them leads to a syntax error:Actual behavior
Steps to reproduce the problem
RuboCop version
The text was updated successfully, but these errors were encountered: