Skip to content
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/AmbiguousRegexpLiteral: auto-correction produces invalid code #8843

Closed
deepj opened this issue Oct 3, 2020 · 0 comments · Fixed by #8847
Closed

Lint/AmbiguousRegexpLiteral: auto-correction produces invalid code #8843

deepj opened this issue Oct 3, 2020 · 0 comments · Fixed by #8847
Labels

Comments

@deepj
Copy link
Contributor

deepj commented Oct 3, 2020

It seems it fails on the regexp literal with method invocation.

Expected behavior

Auto-corrected from assert /#{device_sn_pattern}/.match('1234') to assert(/#{device_sn_pattern}/.match('1234'))

Actual behavior

assert /#{device_sn_pattern}/.match('1234'))

Left parenthesis missing after assert. It breaks Ruby syntax

Steps to reproduce the problem

Code snippet

assert /#{device_sn_pattern}/.match('1234')

Run

rubocop --only Lint/AmbiguousRegexpLiteral -a

RuboCop version

$ rubocop -V
0.92.0 (using Parser 2.7.1.5, rubocop-ast 0.7.1, running on ruby 2.7.1 x86_64-darwin18)
@koic koic added the bug label Oct 3, 2020
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue Oct 3, 2020
…ect when the original node had internal parentheses.
koic added a commit to koic/rubocop that referenced this issue Oct 4, 2020
…gexpLiteral`

Fixes rubocop#8843.

This PR fixes an incorrect autocorrect for `Lint/AmbiguousRegexpLiteral` when
sending method to regexp literal receiver.
@koic koic closed this as completed in #8847 Oct 4, 2020
koic added a commit that referenced this issue Oct 4, 2020
…guous_regexp_literal

[Fix #8843] Fix an incorrect autocorrect for `Lint/AmbiguousRegexpLiteral`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment