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

[Fix #9905] Fix single line concatenation false positive #9911

Merged

Conversation

jonas054
Copy link
Collaborator

@jonas054 jonas054 commented Jul 4, 2021

By checking that the inspected node is multiline, we should get rid of this false positive. Happens for code like

    puts 'a'"#{b}"

We're also checking that none of the children is multiline. This is done to skip weird corner cases that are impossible to have a consistent alignment rule for.

It turns out that the new multiline checks make it possible to remove a couple of old conditions when checking if it's a concatenation with backslashes we're inspecting. It is perhaps possible to search for backslash and newline in the code, but I'd like to avoid that, because I'm afraid of other weird corner cases if we take the regexp search approach.

By checking that the inspected node is multiline, we should
get rid of this false positive. Happens for code like

puts 'a'"#{b}"

We're also checking that none of the children is multiline.
This is done to skip weird corner cases that are
impossible to have a consistent alignment rule for.

It turns out that the new multiline checks make it
possible to remove a couple of old conditions when checking
if it's a concatenation with backslashes we're inspecting.
It is perhaps possible to search for backslash and newline
in the code, but I'd like to avoid that, because I'm
afraid of other weird corner cases if we take the
regexp search approach.
@koic koic merged commit e5db7c0 into rubocop:master Jul 4, 2021
@koic
Copy link
Member

koic commented Jul 4, 2021

Thanks!

@jonas054 jonas054 deleted the 9905_LineEndStringConcatenationIndentation_bug branch July 5, 2021 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants