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

Layout/LineLength splits improperly when a send node has a heredoc argument #9799

Closed
dvandersluis opened this issue May 15, 2021 · 0 comments · Fixed by #9800
Closed

Layout/LineLength splits improperly when a send node has a heredoc argument #9799

dvandersluis opened this issue May 15, 2021 · 0 comments · Fixed by #9800
Assignees
Labels

Comments

@dvandersluis
Copy link
Member

dvandersluis commented May 15, 2021

Extracted from #9749 (comment) by @gregnavis

I'd like to report a similar problem with method calls and heredocs.

In my case, the following method definition:

 def test_unindexed_foreign_keys
   assert_equal(<<~OUTPUT, unindexed_foreign_keys({ "users" => ["profile_id", "account_id"], "account" => ["group_id"] >}))
     account group_id
     users account_id profile_id
   OUTPUT
 end

gets transformed into

 def test_unindexed_foreign_keys
   assert_equal(<<~OUTPUT, 
unindexed_foreign_keys({ "users" => ["profile_id", "account_id"], "account" => ["group_id"] }))
     account group_id
     users account_id profile_id
   OUTPUT
 end

You can see the original method invoked assert_equal with two arguments, the first one defined as a heredoc. The transformed method is syntactically invalid as the second argument and the following closing parenthesis were moved into the heredoc.

@dvandersluis dvandersluis self-assigned this May 15, 2021
dvandersluis added a commit to dvandersluis/rubocop that referenced this issue May 15, 2021
…for `send` nodes with heredoc arguments.
koic added a commit that referenced this issue May 16, 2021
[Fix #9799] Fix invalid line splitting by `Layout/LineLength` for `send` nodes with heredoc arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant