Tools and configuration to locally simulate HoundCi checks
In your Gemfile:
group :development do gem 'hound-tools', '~> 0.0.4', require: false end
Create customizable RuboCop + Hound setup:
$ bundle exec hound-tools init
(NOTE: this runs
rubocop --auto-gen, so it will disable all the offenses.)
Add new files to repository
Add the files to the repository:
git add .hound # default Hound style guide and your overrides git add .rubocop.yml # Rubocop-only config git add .hound.yml # Hound general style-checking config git add .rubocop_merged_for_hound.yml # auto-generated Hound-only config (without Hound defaults)
Customizing your Rubocop/Hound setup
You should only be interested in these files:
.rubocop_todo.yml, which can be updated with
bundle exec rubocop --auto-genand then edited
.hound/overrides.yml, where you can override Hound's default rules or excludes
.rubocop_merged_for_hound.yml- you want to regenerate this and commit
Every time you modify
want to regenerate
$ bundle exec hound-tools
(And then you'll want to add all 3 to the repository before doing anything else).
Once you have your style working, you can simulate Hound with almost 100% accuracy with:
bundle exec rubocop
(If this shows no offenses, check the .rubocop_todo.yml file for disabled rules.)
1) For quickly fixing most offenses, uncomment the 'auto-correct' ones in
.rubocop_todo.yml simply run
bundle exec rubocop -a
2) The RuboCop README has tips on setting up Rake, Guard, etc.
Why is this so complex?
Well, simply because Hound doesn't support the RuboCop
And that's because Hound is avoiding touching the filesystem - which makes
sense since it downloads files to memory from GitHub.
Also, since Hound internally loads it's defaults and does a "mini-merge" of the configurations, it needs a different setup than Rubocop.
I won't mention the clever hacks in Hound to side-step directory traversing and other messy issues (e.g. handling excludes).
1) Using only the default Hound settings (without being able to Hound-check them locally)
2) Copying the default Hound settings (
.rubocop.yml and tweak them (but you loose the flexibility and control of using multiple files and the coolness of .rubocop_todo.yml with 'inherited_from')
- Fork it ( https://github.com/[my-github-username]/hound-tools/fork )
- 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 a new Pull Request