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

Bad autocorrect for Style/RedundantStringEscape #11098

Closed
mvz opened this issue Oct 21, 2022 · 0 comments
Closed

Bad autocorrect for Style/RedundantStringEscape #11098

mvz opened this issue Oct 21, 2022 · 0 comments
Labels

Comments

@mvz
Copy link
Contributor

mvz commented Oct 21, 2022

The following string is auto-corrected incorrectly by Style/RedundantStringEscape:

"#\{foo\}"

Expected behavior

The second escape is not necessary, but the first one is. So one good correction is:

"#\{foo}"

It seems to be more common to escape the # instead, so an alternative good correction is:

"\#{foo}"

Actual behavior

The string is corrected to the following, which is definitely not correct:

"#{foo}"

Steps to reproduce the problem

  • Create a file foo.rb containing
"#\{foo\}"
  • Run rubocop -a foo.rb --only Style/RedundantStringEscape.

RuboCop version

$ [bundle exec] rubocop -V
1.37.0 (using Parser 3.1.2.1, rubocop-ast 1.22.0, running on ruby 3.1.2) [x86_64-linux]
@koic koic added the bug label Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants