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 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)
You should only be interested in these files:
.rubocop_todo.yml
, which can be updated withbundle exec rubocop --auto-gen
and 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 .rubocop_todo.yml
or .hound/overrides.yml
, you'll
want to regenerate .rubocop_merged_for_hound.yml
with:
$ 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.)
-
For quickly fixing most offenses, uncomment the 'auto-correct' ones in
.rubocop_todo.yml
simply runbundle exec rubocop -a
-
The RuboCop README has tips on setting up Rake, Guard, etc.
Well, simply because Hound doesn't support the RuboCop inherited_from
keys.
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).
-
Using only the default Hound settings (without being able to Hound-check them locally)
-
Copying the default Hound settings (
.hound/defaults.yml
) to.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