simplecov
simplecov copied to clipboard
Report only on files in a given directory or matching a given glob
At reek, we're using SimpleCov with RSpec, and have the configuation in .simplecov. We use SimpleCov 0.16.1, and my RUBY_DESCRIPTION is ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux].
Here is our current configuration:
SimpleCov.start do
track_files 'lib/**/*.rb'
add_filter 'lib/reek/version.rb' # version.rb is loaded too early to test
add_filter 'lib/reek/cli/options.rb' # tested mostly via integration tests
end
SimpleCov.at_exit do
SimpleCov.result.format!
SimpleCov.minimum_coverage 98.9
SimpleCov.minimum_coverage_by_file 81.4
end
We are running into the issue that SimpleCov is reporting coverage for our spec files (in spec/). We already have some configuration to make sure all files in lib/ are reported on, except for two which are filtered out. We could add yet another filter to remove spec/, but that seems an open-ended process (e.g., if we were to add coverage information for our cucumber scenarios, we would have to exclude the related step definitions as well).
There is an open pull request where we're trying to improve the situation by setting root, but I don't think that's the right answer, because it breaks other behavior.
There currently seems no configuration that is essentially the inverse of add_filter and makes SimpleCov only report on files matching the given expression, i.e., something like this:
only_report_on 'lib/**/*.rb'
Hi @mvz thanks for your report and thanks for your work on reek! :green_heart: :tada: :rocket:
Seems like a great idea. I think we'd have to establish some hieararchy of how these work together then (only_report_on + add_filter = ?). All of these should be better documented anyhow though see #610
Also sorry a bunch for not responding earlier here, you know time etc. :see_no_evil: