Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RubyMine with Rubocop - How to Reformat?

Tags:

rubymine

I have RuboCop installed with Rubymine and the inspection errors for rubocop are showing up properly.

Running +Alt+L converts the code to rubymine style that conflicts with rubocop style.

For example:

some_array = 10.times.map {|index| index * 3}   # rubymine
some_array = 10.times.map { |index| index * 3 } # rubocop

rubocop puts spaces inside of inline blocks. a small thing I know. but rubymine autoformats without spaces so I have a crapton of of inspection notices.

like image 371
Blair Anderson Avatar asked Apr 27 '17 21:04

Blair Anderson


People also ask

How to format in rubymine?

Reformat a file Either open your file in the editor and press Ctrl+Alt+Shift+L or in the Project tool window, right-click the file and select Reformat Code.

How do I run RuboCop in terminal?

You can run RuboCop using its default settings on your project by typing rubocop (or bundle exec rubocop if installed with Bundler). If you don't pass any arguments to the command, it will check all the Ruby source files in the current directory, as well as all sub directories.


1 Answers

In Rubymine, go to Settings → Editor → Code Style → Ruby and ensure you have the Spaces around curly braces option checked.

enter image description here

like image 196
Matouš Borák Avatar answered Dec 29 '22 00:12

Matouš Borák