This gem provides global RuboCop configurations for ensuring high quality and consistent software development practices.
Due to the ever changing nature of the RuboCop ecosystem — and the fact you can fall behind quickly — this gem takes an aggressive approach to staying atop the latest changes. This also means this gem might never reach Version 1.0.0 because new — often breaking — changes are being introduced in each minor release. That said, if you always want to keep pace with recent changes — because you know how costly technical debt is — then this gem has you covered. 🎉
To install with security, run:
# 💡 Skip this line if you already have the public certificate installed.
gem cert --add <(curl --compressed --location https://alchemists.io/gems.pem)
gem install caliber --trust-policy HighSecurity
To install without security, run:
gem install caliber
You can also add the gem directly to your project:
bundle add caliber
This gem is designed to replace all of your RuboCop setup with only a single reference to this gem.
You’ll want to start with your
Gemfile by adding the following:
group :quality do
Then, in your
.rubocop.yml, add the following to the top of the file:
You can customize the gem by specifying what you need:
The above is what
config/all.yml expands to but now you can mix and match how you like for your specific needs.
When Caliber is added to your
Gemfile, you don’t have to require RuboCop because Caliber does that for you by default. All RuboCop dependencies are also automatically required because they are defined in each configuration. Here’s a full breakdown of how this works:
The above will require and load the configurations for following gems:
When you don’t use the default
all.yml configuration, then behavior changes as follows:
The above will only load the RuboCop Ruby configuration. No further requirements are necessary since Caliber already requires the RuboCop gem by default.
The above will only require the RuboCop Capybara gem and load the associated configuration.
The above will only require the RuboCop Disable Syntax gem and load the associated configuration.
The above will only require the RuboCop FactoryBot gem and load the associated configuration.
The above will only require the RuboCop Packaging gem and load the associated configuration.
The above will only require the RuboCop Performance gem and load the associated configuration.
The above will only require the RuboCop Thread Safety gem and load the associated configuration.
The above will only require the RuboCop Rake gem and load the associated configuration.
The above will only require the RuboCop RSpec gem and load the associated configuration.
Should you not want to include this gem in your project for some reason, you can directly inherit the configuration files supported by this project instead. To do this, you’ll need to add the following to the top of your
You’ll also want to add
.rubocop-https* to your project’s
.gitignore since imported RuboCop YAML configurations will be cached locally and you’ll not want them checked into your source code repository.
If importing all configurations from
all.yml is too much — and much like you can do with requiring this gem directly — you can mix and match what you want to import by defining which configurations you want to use. For example, the following is what
all.yml expands too:
You can also target a specific version of this gem by swapping out the
main path in the YAML URLs listed above with a specific version like
Lastly, when using this YAML import approach, you’ll not benefit from having all gems you need required and installed for you. So you’ll need to manually require these gems in your
In situations where you’d like to use Caliber alongside additional RuboCop gems, you only need to add the new gems to your
Gemfile and then require them within your
.rubocop.yml. For example, let’s say you wanted to use both the Caliber and RuboCop Markdown gems together. Here is how you can use both by updating your
.rubocop.yml (assuming your
Gemfile was updated as well):
Adding additional RuboCop gems only requires adding them to your YAML configuration.
To contribute, run:
git clone https://github.com/bkuhlmann/caliber
You can also use the IRB console for direct access to all objects:
bin/check script — when upgrading to newer RuboCop gem dependencies — to check if
duplicate configurations exist. This ensures Caliber configurations don’t duplicate effort provided
by RuboCop. The script only identifies duplicate Caliber configurations which are enabled and have
no other settings.
When both RuboCop and Caliber are in sync, the following will be output:
RUBY: ✓ CAPYBARA: ✓ DISABLE_SYNTAX: ✓ FACTORY_BOT: ✓ PACKAGING: ✓ PERFORMANCE: ✓ THREAD: ✓ RAKE: ✓ RSPEC: ✓
When RuboCop has finally enabled cops that Caliber already has enabled, the following will display as an example:
RUBY: * Lint/BinaryOperatorWithIdenticalOperands * Lint/ConstantDefinitionInBlock CAPYBARA: ✓ DISABLE_SYNTAX: ✓ FACTORY_BOT: ✓ PACKAGING: ✓ PERFORMANCE: ✓ THREAD: ✓ RAKE: ✓ RSPEC: * RSpec/StubbedMock
The above can then be used as a checklist to remove from Caliber.
To test, run: