BeautifyRuby
BeautifyRuby copied to clipboard
multiline method chaining with leading dots
Hi, just wondering if/how we could get support for the alternative style of method chaining i.e. 'leading dots' - see Option A in the Ruby Style Guide
This project supports trailing dots (Option B) quite well (i.e. . on preceding lines). However if you are using the leading dot notation, it doesnt recognize the block and removes any indentation you might have
User.where(status: ...).
- .order('updated_at DESC')
+ .order('updated_at DESC')
The spec could look like this;
- name: should indent alternative style multiline method call chains
input: |
def method_with_multiline_method_call_chain
multiline_method_call
.foo
.bar
another_method_call
end
output: |
def method_with_multiline_method_call_chain
multiline_method_call
.foo
.bar
another_method_call
end
I wrote a hack to get this to work https://github.com/CraigWilliams/BeautifyRuby/compare/master...gouthamvel:master
Was trying to find a good solution but was hard to find one within the implemented framework. Will see if I can do something better.