Rubocop Zuno

Gem Version CI

Base Rubocop settings for all Zuno Ruby projects.

Requirements

  • Ruby >= 3.2

Installation

Add this line to your application's Gemfile:

group :development, :test do
  # ...
  gem "rubocop-zuno"
end

And then execute:

bundle

Usage

Put this into your .rubocop.yml.

plugins:
  - rubocop-zuno

To enable additional configuration for rubocop-rails and rubocop-rspec, add the following to your .rubocop.yml:

inherit_gem:
  rubocop-zuno:
    - rails.yml # use Rails cops - see Additional Extensions/Cops
    - rspec.yml # use rspec cops - see Additional Extensions/Cops

Creating new custom cops

Use the rake task new_cop to generate a cop template:

$ bundle exec rake 'new_cop[Zuno/Name]'
[create] lib/rubocop/cop/zuno/name.rb
[create] spec/rubocop/cop/zuno/name_spec.rb
[modify] lib/rubocop/cop/boxt_cops.rb - `require_relative 'zuno/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

NewCops is enabled by default.

Additional Extensions/Cops

The following Rubocop gems are also installed with this gem:

rubocop-rails and rubocop-rspec are loaded automatically when you inherit rails.yml or rspec.yml from this gem.

If you want to use cops from rubocop-faker or rubocop-factory_bot, add the relevant plugin to your .rubocop.yml file.

plugins:
  - rubocop-zuno
  - rubocop-faker # if your project uses the Faker gem
  - rubocop-factory_bot # if your project uses FactoryBot

inherit_gem:
  rubocop-zuno:
    - rails.yml # if your project is a Rails app or engine
    - rspec.yml # if your project uses RSpec

Editor Plugins

There are also some useful Rubocop editor plugins to help with in-editor linting.

Atom

RubyMine

VSCode

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/zuno/boxt_rubocop.

License

The gem is available as open source under the terms of the MIT License.