How to tell Rubocop to ignore a specific directory or file
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
Rubocop: how can I exclude a filename pattern from a metric?
You can match files based on a regular expression by using the !ruby/regexp
declaration:
Metrics/LineLength:
Max: 80
AllowHeredoc: true
AllowURI: true
URISchemes:
- http
- https
Exclude:
- !ruby/regexp /_spec\.rb$/
RuboCop recently added a new manual, and you can read about including and excluding files here.
Rubocop ignoring excludes specified in .rubocop.yml
If you run Rubocop from a Rake task, this is expected behaviour. Also see this related issue on Github.
Personally I'd recommend running it from a shell script with command line arguments instead.
To achieve the check for changed files, you can use pronto in conjunction with pronto-rubocop.
RuboCop: Different parameters for different directories
Create separate .rubocop.yml
in /spec
with desired rules. Rubocop will pick it up
RuboCop will start looking for the configuration file in the directory
where the inspected file is and continue its way up to the root
directory.
Ref https://rubocop.readthedocs.io/en/latest/configuration/
How do I suppress Rubocop Conventions?
rubocop --only Syntax,Lint
From https://github.com/bbatsov/rubocop/issues/2337#issuecomment-150477553
If you don't have any custom severity levels in your configuration, it's quite simple. The Synax cop reports on fatal and error level, Lint cops on warning level and all other cops on convention level.
So for only fatal and error, it's rubocop --only Syntax (which is only supported on master, not released yet), and for warningand above it's rubocop --only Lint.
Related Topics
Mongoid: Find Through Array of Ids
Ruby on Rails: How to Check If a File Is an Image
Should I Check in '.Ruby-Gemset' And/Or '.Ruby-Version'
How to Instruct Capistrano 3 to Load My Shell Environment Variables Set at Remote Host
Can a Ruby Script Tell What Directory It's In
Can't Install Rmagick, Pkg-Config: Command Not Found
Devise Skip_Confirmation! Fails to Avoid to Send the Confirmation Instructions
Subtract Dates in Ruby and Get the Difference in Minutes
Add API Key to Every Request in Activeresource
How to Prevent Pipe Character from Causing a Bad Uri Error in Rails 3/Ruby 1.9.2
How to Ignore Multiline Comments in SASS
How to Install 'Cocoapods' Gem from Rubygems.Org (Bad Response Backend Read Error)
How to Specify "Http Request Header" in Openuri
Rails: Switch Connection on Each Request But Keep a Connection Pool
Ruby: Creating a Hash Key and Value from a Variable in Ruby
Turn Off Verbose SQL/Activerecord for Rails 3.1.1
Why Is This Permissions Error Occurring with Mod_Passenger.So
Define_Method: How to Dynamically Create Methods with Arguments