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
Add new Style/StringConcatenation
cop
#8378
Conversation
@@ -39,7 +39,7 @@ def move_comment(eol_comment:, node:, corrector:) | |||
|
|||
text = eol_comment.loc.expression.source | |||
corrector.insert_before(node, | |||
text + "\n" + (' ' * node.loc.keyword.column)) | |||
"#{text}\n#{(' ' * node.loc.keyword.column)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice if the autocorrection dropped those ()
, or maybe should be done by another cop?
RUBY | ||
|
||
expect_correction(<<~RUBY) | ||
users = ("\#{user.name} \#{user.email}") * 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to drop these outer ()
too, but maybe a different cop should do this?
Great PR (as usual 😆) |
I think I like this name better. Might also be a good idea to have the ability to autocorrect using |
2c5a8f6
to
3c30d10
Compare
Style/PreferInterpolation
copStyle/StringConcatenation
cop
Changed name to
Yes, to not complicate the actual implementation and also this is needed in many other cops, so I think it should be better handled by a different cop (named like |
Agreed. I created #8379 to be sure we don't forget 👍 |
https://rubystyle.guide/#string-interpolation
Closes #5067
StringConcatenation
.Safe: false
, because there can be very rare cases where it can give false positives.