My project is extending open-source classes from a third-party gem that we don't want to hold to the same coding standards as our own code. Refactoring the gem code isn't a viable option. We just want Rubocop to ignore the copied code.
How can I instruct Rubocop to completely ignore a file or directory?
By adding the option --exclude-limit COUNT , e.g., rubocop --auto-gen-config --exclude-limit 5 , you can change how many files are excluded before the cop is entirely disabled.
Just create . rubocop. yml file in either in your home directory or in some project directory and override settings you want.
RuboCop's TODO file is generated by the command line option auto-gen-config : rubocop --auto-gen-config. This action runs rubocop across your entire code base, then constructs a set of rule exceptions that effectively 'ignore' code that doesn't fit into the existing guidelines.
The RuboCop behavior can be controlled in the . rubocop. yml file in the root path where you want to execute it. In this file, you can enable/disable certain cops (rules) or change their behavior.
As per orde's comment with the link to the manual I found .rubocop.yml and added the following:
AllCops:
Exclude:
- 'path/to/excluded/file.rb'
where the path is relative to .rubocop.yml
From rubocop/default.yml
:
AllCops:
Exclude:
- 'node_modules/**/*'
- 'vendor/**/*'
Can also consider comments for a single file. Great for ignoring the linter for a quick and dirty temporary task.
# rubocop:disable all
module TempTask
...
end
# rubocop:enable all
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