Is there a way to get Rubocop to format my code every time I save in RubyMine? This was a feature in VSCode, which you were able to set via "editor.formatOnSave": true,
in the settings.json. Is there a similar "autocorrect on save" possibility for Rubymine?
From the main menu, go to Code | Analyze Code | Run Inspection by Name Ctrl+Alt+Shift+I. In the popup, find RuboCop and press Enter. In the Run 'RuboCop' dialog, specify the scope of files that you want to analyze. If necessary, enable Use 'standard' gem. Click OK. Wait until RubyMine analyzes your project.
.rubocop.yml. RubyMine takes into account all settings specified in the .rubocop.yml file. For example, if you disable some checks for a specified cop department, the editor will not show corresponding offenses. Moreover, these offenses won't be shown in the RuboCop inspection report.
See Auto-correct for more details. RuboCop comes with a preconfigured set of rules for each of its cops, based on the Ruby Style Guide . Depending on your project, you may wish to reconfigure a cop, tell to ignore certain files, or disable it altogether.
(Optional) Assign a shortcut for the created action. In the Settings/Preferences dialog Ctrl+Alt+S, select Keymap, find the Fix Layout action under the RuboCop node and specify a shortcut. To run the created RuboCop action, go to the Tools main menu or use the context menu of a file.
As of RubyMine 2021.3 this is now explicitly supported as a feature:
https://blog.jetbrains.com/ruby/2021/10/rubymine-2021-3-eap5/#run_rubocop_on_save
Unfortunately at the moment it's not possible so please add your votes to the corresponding feature requests:
https://youtrack.jetbrains.com/issue/RUBY-19589
https://youtrack.jetbrains.com/issue/RUBY-27248
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With