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
When Style/RedundantStringEscape sees a string like this
"\#\{foo}"
it identifies both \# and \{ as redundant string escapes, and if asked to autocorrect, will unescape both, changing the meaning of the program.
Expected behavior
Because Style/RedundantStringEscape promises safe autocorrection, I would expect that it would change the offending string to either"#\{foo}" (removing first slash) or "\#{foo}" (removing second slash).
Actual behavior
It actually removes both, resulting in #{foo}. This causes the program to interpolate the value of foo.
Steps to reproduce the problem
Assuming RuboCop is installed, this script will demonstrate the problem:
…cape`
Fixesrubocop#11309.
This PR fixes a false positive for `Style/RedundantStringEscape`
when using a redundant escaped string interpolation `\#\{foo}`.
When Style/RedundantStringEscape sees a string like this
"\#\{foo}"
it identifies both
\#
and\{
as redundant string escapes, and if asked to autocorrect, will unescape both, changing the meaning of the program.Expected behavior
Because Style/RedundantStringEscape promises safe autocorrection, I would expect that it would change the offending string to either
"#\{foo}"
(removing first slash) or"\#{foo}"
(removing second slash).Actual behavior
It actually removes both, resulting in
#{foo}
. This causes the program to interpolate the value offoo
.Steps to reproduce the problem
Assuming RuboCop is installed, this script will demonstrate the problem:
Here is the output:
RuboCop version
The text was updated successfully, but these errors were encountered: