dkubb / yardstick

A tool for verifying YARD documentation coverage
http://wiki.github.com/dkubb/yardstick
MIT License
173 stars 22 forks source link

Support for overriding from a .yardstick.yml file or --config command option #50

Open dhedlund opened 6 years ago

dhedlund commented 6 years ago

This pull request fixes issue #24.

The pull request:

Description

Support for the default config override should apply to the yardstick command, as well as rake files. When looking for a default config, it searches up the directory tree until it finds either a .yardstick.yml or it reaches the bundler root directory where the Gemfile is usually kept.

The config override behavior is naive in that it does not attempt to perform a deep merge of the rules hash; there is currently no use case that would require a deep merge, as the hashes passed through Yardstick#coerce are never set to anything complicated within the gem. The primary use case for deep merging rules would be projects that have had to work around not having a way to specify default overrides that have hacked up their Rakefile or written a wrapper script that sets the configuration manually. Because passed hashes and code blocks take precedent, they should continue to work the same way as before this pull request.

Forcing the user to provide a path or set of paths when executing the yardstick command no longer makes sense as the path can be set in the .yardstick.yml; it would not be possible to use that value, and would always be overridden by the command line. It is also inconsistent with the rake tasks that have no way to provide a path from the command line. The path can still be specified, but has been made optional.

A -c FILE and --config FILE option was added to the yardstick command for specifying a custom configuration file. If the option is given then the config file must exist or an error will be displayed. If a custom config and exists, it is used instead of the .yardstick.yml file; it does not act as an override of the configuration within the default config file.

Tests / Rubocop

Every attempt was made to include test coverage for all changes and simplecov still reports coverage at 100%. Rubocop appears to non longer be working for the project due to changes in rubocop over time. After resolving the hard failures encountered when running bundle exec rake ci due to configuration file changes, there were still a large number of unrelated offenses. The rubocop fixes are outside the scope of this pull request and should be handled as a separate issues / pull request.