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
I would expect Rubocop to not flag multi-line regular expressions with comments as invalid.
Actual behavior
End up with the following error:
Lint/MixedRegexpCaptureTypes: Do not mix named captures and numbered captures in a Regexp literal.
Steps to reproduce the problem
You can recreate the issue as follows:
# frozen_string_literal: trueSUCCESS=/ (?<key>\A.+)/x.freezeFAILURE=/ (?<key>\A.+) # Key (anchored to start of line)./x.freeze
If you save the above to example.rb and run rubocop example.rb, you'll get the following error:
Inspecting 1 file
W
Offenses:
example.rb:3:19: W: Lint/MixedRegexpCaptureTypes: Do not mix named captures and numbered captures in a Regexp literal.
PATTERN_FAILURE = / ...
^
1 file inspected, 1 offense detected, 1 offense auto-correctable
This is a false positive with Rubocop where comments with a multi-line
regular expression cause Rubocop to flag this as a violation. I've
logged an [issue](rubocop/rubocop#8845) to
address this.
🙇 @dvandersluis Perfect. I was searching for open/closed issues related to Lint/MixedRegexpCaptureType but didn't see that at all. I look forward to the next release.
Expected behavior
I would expect Rubocop to not flag multi-line regular expressions with comments as invalid.
Actual behavior
End up with the following error:
Steps to reproduce the problem
You can recreate the issue as follows:
If you save the above to
example.rb
and runrubocop example.rb
, you'll get the following error:RuboCop version
The text was updated successfully, but these errors were encountered: