Home > front end >  Setup RubyMine to use custom rubocop file
Setup RubyMine to use custom rubocop file

Time:12-19

I am using the RubyMine IDE for a rails project and want to configure RubyMine to use my custom .rubocop.yml file.

The only thing close to what I'm looking for that I could find is this rubocop page that describes how to add a rubocop action. The issue with this is that creating a rubocop action only allows for a single cop/formatter at a time. This is far from ideal since my custom .rubocop.yml file contains almost three hundred formatting rules.

A temporary workaround I have is to copy my .rubocop.yml file into the root directory of my project in RubyMine and then from a terminal at the root directory I can run rubocop path/to/file.rb to see all of the offenses. This also is not practical because running this manually on all files I'm editing across different directories is time consuming.

Does anyone know how to setup/configure RubyMine IDE to use a custom .rubocop.yml file? Additionally, it would be nice if the inspections tool that highlights offenses for the current file in scope indicates the offenses found via the custom .rubocop.yml.

CodePudding user response:

Seems like maybe your specific project is damaged ?

Have you tried to recreate the project? Since RuboCop is enabled by default in RubyMine. Maybe you can try to remove .idea folder and Reopen the project like if it was a new project. Perhaps that you enable the RuboCop again. Also make sure that RuboCop Gem is accessible to RubyMine, either locally in the Gemfile or Globally and make sure that your version of ruby is the same in command line and RubyMine selection. If RubyMine is not able to find the RuboCop Gem then it will not engage it.

https://www.jetbrains.com/help/ruby/rubocop.html

CodePudding user response:

At the moment RubyMine uses .rubocop.yml file placed in the project's root, but there's feature request for implementing the ability you'd like to have:

https://youtrack.jetbrains.com/issue/RUBY-26668/Allow-to-specify-custom-rubocop-config-file

  • Related