Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align multiple method calls for Ruby in RubyMine

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?

like image 243
Denys Husiev Avatar asked Jun 25 '26 10:06

Denys Husiev


1 Answers

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.

like image 137
Andrey Aksyonov Avatar answered Jun 28 '26 11:06

Andrey Aksyonov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!