We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When Rubocop encounters '"' + "foo" + '"' it should be autocorrected to '"foo"'
'"' + "foo" + '"'
'"foo"'
When Rubocop 1.1.0 encounters '"' + "foo" + '"' it currently autocorrects to ""foo"" thus leading to a syntax error:
""foo""
test.rb:3:3: C: [Corrected] Style/StringConcatenation: Prefer string interpolation to string concatenation. p '"' + "foo" + '"' ^^^^^^^^^^^^^^^^^ test.rb:3:5: E: Lint/Syntax: unexpected token tIDENTIFIER (Using Ruby 2.4 parser; configure using TargetRubyVersion parameter, under AllCops) p ""foo""
Create a Ruby file with the following line and run rubocop -A in its directory '"' + "foo" + '"'
rubocop -A
$ rubocop -V 1.1.0 (using Parser 2.7.2.0, rubocop-ast 1.1.0, running on ruby 2.7.2 x86_64-linux)
This is a bug specific to double quotes in single quotes. "\"" + 'foo' + "\"" is properly autocorrected to '"foo"'.
"\"" + 'foo' + "\""
The text was updated successfully, but these errors were encountered:
Agreed.
It should also handle '"' + "'" and either correct using %Q{...} or not correct at all.
'"' + "'"
%Q{...}
Sorry, something went wrong.
I couldn't reproduce on the master branch. Maybe #8893 or #8830 fixed it.
Style/StringConcatenation
[Fix rubocop#8985] Fix Style/StringConcatenation autocorrect genera…
ccb7102
…ting invalid ruby When single quoted strings Closes rubocop#8985
[Fix #8985] Fix Style/StringConcatenation autocorrect generating in…
d58d248
…valid ruby When single quoted strings Closes #8985
Successfully merging a pull request may close this issue.
Expected Behavior
When Rubocop encounters
'"' + "foo" + '"'
it should be autocorrected to'"foo"'
Actual Behavior
When Rubocop 1.1.0 encounters
'"' + "foo" + '"'
it currently autocorrects to""foo""
thus leading to a syntax error:Steps to reproduce the problem
Create a Ruby file with the following line and run
rubocop -A
in its directory'"' + "foo" + '"'
RuboCop version
Note
This is a bug specific to double quotes in single quotes.
"\"" + 'foo' + "\""
is properly autocorrected to'"foo"'
.The text was updated successfully, but these errors were encountered: