Skip to content

Instantly share code, notes, and snippets.

@ziaulrehman40
Last active October 8, 2022 14:35
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ziaulrehman40/8cf573331b14d10b0a88b1221956f1a9 to your computer and use it in GitHub Desktop.
Save ziaulrehman40/8cf573331b14d10b0a88b1221956f1a9 to your computer and use it in GitHub Desktop.
Rubocop config

Add following to Gemfile

group :development, :test do
  gem 'rubocop'
  gem 'rubocop-performance'
  gem 'rubocop-rails'
  gem 'rubocop-minitest' # or gem 'rubocop-rspec' depending on your test suite
end

And than create .rubocop.yml file at root fo your project and add following to it:

require: 
  - rubocop-performance
  - rubocop-rails
  - rubocop-rspec # or rubocop-minitest
 
 
AllCops:
  # Exclude auto-generated files by Rails
  TargetRubyVersion: 2.7
  TargetRailsVersion: 5.2
  Exclude:
    - 'db/schema.rb'
    - 'node_modules/**/*'
    - 'vendor/bundle/**/*'
    - 'bin/**/*'
    
Layout/LineLength:
  Max: 120
  
Metrics/MethodLength:
  Max: 23

Metrics/BlockLength:
  Exclude:
    - config/**/*
    - spec/**/*

Lint/AmbiguousBlockAssociation:
  Exclude:
    - spec/**/*

Style/Documentation:
  Enabled: false

Obviously, you can tune the config file as per your rpeferences. Enjoy.

@asfandDev
Copy link

Metrics/LineLength:
Max: 120

Above namespace is update to

Layout/LineLength:
Max: 120

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment