- Go to Settings > Tools > External Tools
- Click "+" to add a new tool. Copy the details below, (replace /home/patrick/bin with /home/<YOUR_USER>/bin)
- Create an empty Rubocop script using this command:
mkdir -p $HOME/bin && touch $HOME/bin/rubocop.sh && chmod +x $HOME/bin/rubocop.sh
- Open rubocop.sh in your favorite editor (RubyMine, obviously) and save this:
#!/bin/sh
eval "RBENV_VERSION=2.7.4 bundle exec rubocop $@"
NOTE: If you're not using rbenv, remove it. Or change it to match your Ruby version.
- Add a Keymap in RubyMine. I use
^+⌘+L
in MacOS or^+Alt+L
in Linux.
-
Test it by opening a file and pressing the Keymap sequence.
-
(Optional) Repeat the process by adding another External Tool, bind it to a different Keymap, but enable showing the console. This is useful if you ever want to see Rubocop's output.
Nice, but do you really need all that?
This has always worked on my setup: