How to speed up Rubocop's startup time
If you have a fairly complex .rubocop.yml file, you may find that later versions take forever to start up or report results, and it seems like it hanging when you run it manually from the CLI.
The cause for this may be due to you having custom exclusion rules. When you exclude files from Rubocop ala:
AllCops:
Exclude:
- 'db/fixtures/**/*'
- 'db/migrate/*.rb'
- 'db/schema.rb'
- 'db/seeds.rb'
- 'Gemfile.lock'
- 'bin/*'
# ... etc... etc... Rubocop will then ignore any of its own exclusion rules, and land up scanning node_modules, cache dirs, log dirs, and even your .git folder!
You can fix this by adding the following into your .rubocop.yml file.
inherit_mode:
merge:
- ExcludeRubocop will now merge in its default exclusion list alongside your own.
Why this is not the default behaviour eludes me. :|
Tweet