gl_rubocop
A shareable configuration of rules we use at Give Lively to lint our Ruby code.
Installation
Add this line to your application's Gemfile:
gem 'gl_rubocop', require: false
And then execute:
bundle install
Or install it yourself as:
gem install gl_lint
And finally add this to the top of your project's RuboCop configuration file:
inherit_gem:
gl_rubocop: default.yml
Any Include
or Exclude
configuration provided will be merged with RuboCop's defaults.
For more information about inheriting configuration from a gem please check RuboCop's documentation.
Making changes and publishing
-
As per our code agreements, all code changes to this gem are required to be made via pull request with final approval from at least one Give Lively engineer.
-
When creating a pull request, ensure that your code changes include an update to the gem's version number using semantic versioning
-
After getting approval, merge your changes to
main
. -
Once your CI build finishes sucessfully, pull the latest version of
main
locally. -
Run the command
gem build
. This bundles the relevant files from the gem and prepares it to be published to rubygems.org. (Note: if you are not one of the owners listed you may need to request that that this and the following step be completed by one of the gem owners listed in CODEOWNERS) -
Once the bundle is successfully created there should be a new file created locally that looks like
gl_rubocop-<new_gem_version_number>.gem
. -
Run the command
gem push gl_rubocop-<new_gem_version_number>.gem
. -
Following the authorization prompts listed by the gem command.
-
Your changes have now been published to the rubygems registry.
Testing Locally
It's likely the case you'll want to test your changes locally before opening a PR, getting approval, and publishing the gem.
To do so, complete the following steps:
-
Save the changes to whichever files you have modified.
-
Run the command
gem build
to create the bundle (this may require you to have bumped the version number) -
Go to the Gemfile in whichever ruby-based repo you want to test your rubocop changes against
-
Create an entry for gl_rubocop specifiying the relative path to your local
gl_rubocop
repo (ex.../code/gl_rubocop
):
gem 'gl_rubocop', '~> 0.2.9', path: '../path/to/your/local/gl_rubocop'
-
Within the same repo as the Gemfile you just updated run
bundle install
-
Finally add the following lines to your rubocop configuration file
inherit_gem:
gl_rubocop: default.yml
- Now you can test your rubocop changes local with the target repo.