Long chains of method calls should be formatted one per line
See original GitHub issueInput
Person
.select('people.id, people.name, comments.text')
.joins(:comments)
.where('comments.created_at > ?', 1.week.ago)
Current output
Person.select('people.id, people.name, comments.text').joins(:comments).where(
'comments.created_at > ?', 1.week.ago
)
Expected output
Person
.select('people.id, people.name, comments.text')
.joins(:comments)
.where('comments.created_at > ?', 1.week.ago)
or maybe
Person.select('people.id, people.name, comments.text')
.joins(:comments)
.where('comments.created_at > ?', 1.week.ago)
I’d be willing to help implement this change if we decide it’s a good idea, however I’d need a little guidance on how to go about doing that.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:33
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Python: Formatting Chained Methods - Ken Goettler
Chained method calls might be too long for a single line. ... To keep a chained method compliant with a 79-character line length,...
Read more >Chained method calls indentation style in Python [duplicate]
This is a case where a line continuation character is preferred to open parentheses. ShortName.objects.distinct() \ .filter().values() ...
Read more >JavaScript Code Styling Best Practices — Method Calls and ...
In this article, we'll look at formatting chain of method calls, the use of the Array constructor and the use of other less...
Read more >489444 – [Formatter] Chained method calls when ... - Bugs
Various builder libraries would automatically format one .withX(x) per line with this convention as well, and Stream objects do the right thing by...
Read more >C# at Google Style Guide | styleguide
For function definitions and calls, if the arguments do not all fit on one line they should be broken up onto multiple lines,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hot damn. This is finally closed. It’ll be out in the next release.
I’d imagine there will be more follow up on it, but we can open new issues.
It seems like this could help with another case:
Input
Current Output
Expected output
Using the expected output as input yields the same result.