ShopStormCops
ShopStormCops is a little library that integrates RuboCop into your Ruby project, configured for following the coding conventions we use at SkyVerge (ShopStorm division). It is planned to add more 3rd party coding style tools in the future.
Installation
Add the gem into your Gemfile’s development and test groups:
group :development, :test do
gem 'shop_storm_cops'
end
And then execute:
$ bundle install
Usage
Rubocop integration
ShopStormCops adds RuboCop as a dependency and provides you with a shared cop file based in the coding conventions of SkyVerge. For use it you should create a .rubocop.yml
file into your root rails directory with the following content:
# .rubocop.yml file located into the root rails directory
inherit_gem:
shop_storm_cops: lib/shop_storm_cops/rubocop/shared_cops.yml
With inherit_gem
, you’re configuring RuboCop for inheriting from a file inside this actual gem. You can review the shared cops in shared_cops.yml
. Now you’re free to execute the RuboCop standalone command with:
$ bundle exec rubocop
You’re free to configure your .rubocop.yml
file for inheriting also from a local file, like from .rubocop_todo.yml
, as it is the typical workflow. This is how it’d look:
# .rubocop.yml file located into the root rails directory
inherit_gem:
shop_storm_cops: lib/shop_storm_cops/rubocop/shared_cops.yml
inherit_from:
- .rubocop_todo.yml
The file inherited via inherit_from
will have more preference than the one inherited from the gem, so the repeated Cops would be overwritten according to https://github.com/bbatsov/rubocop#inheriting-configuration-from-a-dependency-gem.
Common commands
bundle exec rubocop
: Run the conventions suite.bundle exec rubocop —auto-gen-config
: Automatically generates the.rubocop_todo.yml
according to the current offences.bundle exec rubocop —auto-correct
: Auto correct the current offences automatically. Use with caution. Intensive revision of the changes and the run of the test suite will be needed after using the auto correction. Not all the Cops implement auto correction, only some of them.
Take a look at the https://github.com/bbatsov/rubocop documentation for a more advanced use.
Future platforms to integrate
Contributing
We follow the GitHub Flow model:
- Check for issues of your interest or create a new one.
- Fork the repo ( http://github.com/skyverge/shopstorm-cops/fork ).
- Create your branch with a descriptive name, prefixed with the type (feature, chore, bug, release) and the related issue number. (
git checkout -b feature/my-new-feature
). - Implement a test covering what you’re going to develop.
- Push your branch with your changes and send us a pull request.
Many thanks! :)
License
The gem is available as open source under the terms of the MIT License.