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.
Metrics/LineLength:
Max: 120
Above namespace is update to
Layout/LineLength:
Max: 120