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
If we enable the Style/RegexpLiteral rule together with Style/MethodCallWithArgsParentheses using the EnforcedStyle omit_parentheses, RuboCop incorrectly recommends using // around a regular expression when the %r style is needed to avoid an ambiguous first argument.
Fixesrubocop#9874.
This PR fixes a false positive for `Style/RegexpLiteral`
when using `%r` regexp literal with `EnforcedStyle: omit_parentheses` of
`Style/MethodCallWithArgsParentheses`.
If we enable the Style/RegexpLiteral rule together with Style/MethodCallWithArgsParentheses using the EnforcedStyle omit_parentheses, RuboCop incorrectly recommends using // around a regular expression when the %r style is needed to avoid an ambiguous first argument.
Expected behavior
Consider the following rules:
Now consider the following code:
We expect RuboCop to be fine with this code because %r is needed to avoid an ambiguous first argument warning from Ruby.
Actual behavior
RuboCop reports the following problem:
If we take away the %r, Ruby reports the following warning:
I think RuboCop should recognize this situation and allow for the use of %r in this case.
RuboCop version
The text was updated successfully, but these errors were encountered: