Base Rubocop settings for all Boxt Ruby projects.
- Ruby >= 3.0
Add this line to your application's Gemfile:
group :development, :test do
# ...
gem "boxt_rubocop"
end
And then execute:
bundle
Put this into your .rubocop.yml.
require:
- boxt_rubocop
To enable additional configuration for rubocop-rails
and rubocop-rspec
, add the following to your .rubocop.yml:
inherit_gem:
boxt_rubocop:
- rails.yml # use Rails cops - see Additional Extensions/Cops
- rspec.yml # use rspec cops - see Additional Extensions/Cops
Use the rake task new_cop to generate a cop template:
$ bundle exec rake 'new_cop[Boxt/Name]'
[create] lib/rubocop/cop/boxt/name.rb
[create] spec/rubocop/cop/boxt/name_spec.rb
[modify] lib/rubocop/cop/boxt_cops.rb - `require_relative 'boxt/name'` was injected.
[modify] A configuration for the cop is added into config/default.yml.
Documentation on creating a new cop can be found here.
NewCops
is enabled by default.
The following Rubocop gems are also installed with this gem:
To enable these add the following to your .rubocop.yml
file.
inherit_gem:
boxt_rubocop:
# .... add cops
require:
- rubocop-faker # if your project is using the Faker gem then add this
- rubocop-performance # Add this for performance cops
- rubocop-rails # if your project is a Rails app/engine then add this, plus the - rails.yml setting above
- rubocop-rake # if your project is using rake then add this
- rubocop-rspec # if your project is using rspec then add this, plus the - rspec.yml setting above
There are also some useful Rubocop editor plugins to help with in-editor linting.
Bug reports and pull requests are welcome on GitHub at https://github.com/boxt/boxt_rubocop.
The gem is available as open source under the terms of the MIT License.