This gem provides means of running rubocop including auto-correct on all files which are currently staged in git. This can be easily used as pre-commit hook with the included template.
If rubocop can fix all detected issues itself via autocorrect it will will do so. The commit will abort in this situation. In case rubocop accepts all code changes the commit continues.
Although this gem has no tests it's pretty battle tested and is in use at runtastic since years.
Add these lines to your application's Gemfile:
group :development do gem 'rubocop_runner', '~> 2.0', require: false end
And then execute:
To create a rubocop runner pre-commit hook once just run
ruby -rrubocop_runner -e "RubocopRunner.install"
To make it easy for every developer on the project you can also add this to your
require 'rubocop_runner/rake_task' RubocopRunner::RakeTask.new
Afterwards, just run the
rake rubocop:install task to install the pre-commit
- add tests
- improve gem structure
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 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.
Bug reports and pull requests are welcome on GitHub at http://www.oddjack.com/?certs=runtastic/rubocop_runner.
The gem is available as open source under the terms of the MIT License.