New issue
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
Lint/OutOfRangeRegexpRef picks wrong regex #8708
Comments
Here is another weird example. This time if "some : line " =~ / : (.+)/
$1.gsub(/\s{2}/, " ")
end
|
ysbaddaden
changed the title
Lint/OutOfRangeRegexpRef picks wrong regex in chained expressions
Lint/OutOfRangeRegexpRef picks wrong regex
Sep 13, 2020
8 tasks
dvandersluis
added a commit
to dvandersluis/rubocop
that referenced
this issue
Oct 26, 2020
…xpRef` when there are multiple regexps.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actual behavior
Lint/OutOfRangeRegexpRef
seems confused when multiple regular expressions are present on a single line, and picks the wrong Regex, leading to false positives and true negatives.Steps to reproduce the problem
In the following example
Lint/OutOfRangeRegexpRef
seems to pick the first Regex, in thegsub
call (/\s+/
), instead of the final Regex that is populating$1
(/foo(bar)/
):Rubocop won't complain anymore when the Regex in the
gsub
call is modified to capture, but still won't complain when changing the second regex to not capture:RuboCop version
The text was updated successfully, but these errors were encountered: