Skip to content

voxpupuli/voxpupuli-rubocop

Vox Pupuli RuboCop Gem

License Test Release RubyGem Version RubyGem Downloads

This is one of the Vox Pupuli meta gems. It provides a convenient way to configure RuboCop. RuboCop is the de facto standard Ruby Linter and Formatter. voxpupuli-rubocop depends on the correct RuboCop version

  • dependencies that we want to use in our CI pipelines. There is also a rubocop.yml that configures RuboCop. and preconfigured rake tasks.

The goal of this gem is to provide a central configuration for RuboCop that's used in all Vox Pupuli gems.

Usage

In your Gemfile, add the following:

gem 'voxpupuli-rubocop', '~> 2.1.0'

We suggest to pin the minor version like above, because new minor versions will pull in newer rubocop versions

(A best practice, that we also follow in our Vox Pupuli Ruby Gems, is to pin like above and use dependabot. It will provide pull requests that allow newer minor versions. And in a CI pipeline you will see if the newer rubocop works without issues. That prevents your HEAD branch from breaking. If you've multiple repositories in your GitHub Org, you can filter for all dependabot PRs by checking for label:ruby label:dependencies Vox Pupuli example).

In your Rakefile, include our Rake task:

require 'voxpupuli/rubocop/rake'

Now you can list your rake tasks and should see three new ones:

bundle exec rake -T
rake rubocop                  # Run RuboCop
rake rubocop:autocorrect      # Autocorrect RuboCop offenses (only when it's safe)
rake rubocop:autocorrect_all  # Autocorrect RuboCop offenses (safe and unsafe)

To use our default config, create a .rubocop.yml:

---
inherit_gem:
  voxpupuli-rubocop: rubocop.yml

You maybe see a bunch of violations with the new configuration. A common path forward is to accept them but prevent future/more violations. You can generate a "RuboCop ToDo file", which is basically an allow-list of all current violations:

bundle exec rubocop --regenerate-todo

New major releases

As described above, we will do new minor releases of voxpupuli-rubocop with newer RuboCop dependencies. We also ship a rubocop.yml that people can use. This file currently configures Ruby 2.7 as a target version. This will be adjusted in major releases.

User of voxpupuli-rubocop don't have to use our rubocop.yml, they can just rely on our curated list of rubocop dependencies. Or overwrite the target version in their own rubocop.yaml:

inherit_gem:
  voxpupuli-rubocop: rubocop.yml

AllCops:
  TargetRubyVersion: '3.3'

About

metagem that provides RuboCop + configs. Used in our gems

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Languages