Rubocop Platanus
A RuboCop extension for enforcing Platanus best practices and code style.
Installation
gem install rubocop-platanus
Or add to your Gemfile:
gem "rubocop-platanus"
bundle install
Usage
You need to tell RuboCop to load the Platanus extension. There are three ways to do this:
RuboCop configuration file
Put this into your .rubocop.yml.
require: rubocop-platanus
Alternatively, use the following array notation when specifying multiple extensions.
require:
- rubocop-other-extension
- rubocop-platanus
Now you can run rubocop and it will automatically load the RuboCop Platanus cops together with the standard cops.
Command line
rubocop --require rubocop-platanus
Testing
To run the specs you need to execute, in the root path of the gem, the following command:
bundle exec guard
You need to put all your tests in the /my_gem/spec/
directory.
Development
To create a new cop, you need to execute, in the root path of the gem, the following command:
$ bundle exec rake 'new_cop[Foobar/SuperCoolCopName]'
[create] lib/rubocop/cop/foobar/super_cool_name.rb
[create] spec/rubocop/cop/foobar/super_cool_name.rb
[modify] lib/rubocop/cop/potassium_cops.rb - `require_relative 'foobar/super_cool_name'` was injected.
[modify] A configuration for the cop is added into config/default.yml.
Do 4 steps:
1. Modify the description of Foobar/SuperCoolCopName in config/default.yml
2. Implement your new cop in the generated file!
3. Commit your new cop with a message such as
e.g. "Add new `Foobar/SuperCoolCopName` cop"
4. Run `bundle exec rake changelog:new` to generate a changelog entry
for your new cop.
Resources
To create new cops and node matchers, follow these resources on node pattern syntax:
Publishing
On master/main branch...
- Change
VERSION
inlib/rubocop-platanus/version.rb
. - Change
Unreleased
title to current version inCHANGELOG.md
. - Run
bundle install
. - Commit new release. For example:
Releasing v0.1.0
. - Create tag. For example:
git tag v0.1.0
. - Push tag. For example:
git push origin v0.1.0
.
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Credits
Thank you contributors!
Test Gem is maintained by platanus.
License
Test Gem is © 2022 platanus, spa. It is free software and may be redistributed under the terms specified in the LICENSE file.