Reputation: 41
We use rubocop in our project and it enforces us to align our chain method calls. I used to use RubyMine linter, but it places methods with indent of 2 spaces from beginning of variable.
I tried to find this setting in Preferences > Editor > Code Style > Ruby, but seems they don't have this option for Ruby.
JavaScript has this under Preferences > Editor > Code Style > JavaScript > Wrapping and Braces > Chained method calls > Align when multiline
# bad
variable.m1
.m2
.m3
# good
variable.m1
.m2
.m3
Do we have this option in RubyMine? Or how can we add some custom .editorconfig setting for this? Or maybe there are other options?
Upvotes: 3
Views: 752
Reputation: 331
Starting with 2019.3, RubyMine has an option for aligning chained method calls by the initial receiver or leading dots for the Ruby language. You can configure it in the same way as for JavaScript: open the Settings/Preferences | Editor | Code Style | Ruby | Wrapping and Braces page and go to the Chained method calls | Alignment option.
Upvotes: 1
Reputation: 2345
It isn't currently supported, but there is an open ticket: RUBY-17293 (The specific alignment style you're looking for was filed as RUBY-18797, but it was closed as a duplicate). A comment indicates that it was planned for the 2019.1 release, but it doesn't appear to have made it in. (You can vote for the ticket if you make a YouTrack account, but I don't how that influences issue priorities.) One option in the interim would be to use Rubocop quick-fixes.
Upvotes: 0