How to tell Rubocop to ignore a specific directory or file How to tell Rubocop to ignore a specific directory or file ruby ruby

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


From rubocop/default.yml:

AllCops:  Exclude:    - 'node_modules/**/*'    - 'vendor/**/*'


For your convenience, here is the .rubocop.yml I frequently used.

See formal explanation of .rubocop.yml here.

AllCops:  Exclude:    - Berksfile    - recipes/basic.rb    - attributes/*.rb# Customize rulesMetrics/LineLength:  Max: 95MethodLength:  Max: 35Metrics/AbcSize:   Enabled: falseBlockLength:  Max: 70

I constantly bump by rubocop errors and warning. Thus I've published this post.

Common Rubocop Errors: Improve Your Ruby Code Quality