CarwowRubocop
carwow specific analysis for RuboCop.
It contains carwow's internally used configuration for RuboCop and RuboCop RSpec. It also includes a handful custom rules that are not currently addressed by other projects.
Installation
Just put this in your Gemfile it depends on the appropriate version of rubocop and rubocop-rspec.
gem 'carwow_rubocop'
And then execute:
$ bundle
Or install it yourself as:
$ gem install carwow_rubocop
Usage
You need to tell RuboCop to load the carwow extension. There are three ways to do this:
RuboCop configuration file
First Create a new file .rubocop_carwow.yml in the same directory as your .rubocop.yml
this file should contain
require:
- carwow_rubocop
Next add the following to .rubocop.yml
or add before .rubocop_todo.yml in your existing inherit_from
inherit_from:
- .rubocop_carwow.yml
- .rubocop_todo.yml
You need to inherit .rubocop_carwow.yml from another file because of Rubocop order of operations.
It runs inherit_from before require commands. If the configuration is not in a separate file
you could potentially experience a bunch of warnings from .rubocop_todo.yml for non-existant
Carwow rules.
Now you can run rubocop and it will automatically load the RuboCop Carwow
cops together with the standard cops.
Command line
rubocop --require rubocop-carwow
The Cops
All cops are located under
lib/rubocop/cop/carwow, and contain examples/documentation.
In your .rubocop.yml, you may treat the carwow cops just like any other cop. For example:
Carwow/NoStubbingBusinessEvent:
Exclude:
- spec/my_poorly_named_spec_file.rb
Development
After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install.
To update the carwow rubocop rules, edit the file: config/default.yml.
To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/carwow_rubocop.
How to write custom cops?
The official docs will teach you how to develop new cops.
Read Node pattern to understand better how to write node matches for your custom cop.
How other companies are doing it?
There are a lot of companies with public repositories sharing their Cops.
License
The gem is available as open source under the terms of the MIT License.