Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds option to track uncovered source files. #422

Merged

Conversation

hugopeixoto
Copy link
Contributor

Fixes #413

Added a configuration option track_files that accepts
a glob. With this enabled, coverage result will include
uncovered files that match the glob.

In the rails profile this is set to {app,lib}/**/*.rb

Regarding line count issue:

It is not easy to determine which lines should be classified as relevant (this is done by the ruby parser), so this implementation does not touch the coverage information for covered files, to avoid ruining the accurate percentages.
When handling uncovered files it uses an approximation function to determine if the line is relevant or not, based on the code present in #16. As uncovered files have 0% coverage, this will only affect the global percentage, so I don't think it's an issue.

@hugopeixoto hugopeixoto changed the title Adds option to track uncovered source files (Fixes #413) Adds option to track uncovered source files. Fixes #413 Oct 25, 2015
@hugopeixoto hugopeixoto changed the title Adds option to track uncovered source files. Fixes #413 Adds option to track uncovered source files. Oct 25, 2015
@@ -49,11 +49,44 @@ def start(profile = nil, &block)
end

#
# Finds files that were to be tracked but were not covered and initializes
# their coverage to zero, with an estimation of the line count.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/covered/loaded

@xaviershay
Copy link
Collaborator

Looks like this is just about ready - a typo remains. I'm not sure whether the discussion about @track_files_glob is resolved?

@hugopeixoto
Copy link
Contributor Author

I'll apply the suggestion to mark the whole file as uncovered, instead of having a function to validate the lines (and fix the typo).

Added a configuration option `track_files` that accepts
a glob. With this enabled, coverage result will include
uncovered files that match the glob.

In the `rails` profile this is set to `{app,lib}/**/*.rb`
@hugopeixoto
Copy link
Contributor Author

The builds are failing due to unrelated issues which are fixed in #425, by @xaviershay.

@xaviershay xaviershay merged commit 81e2431 into simplecov-ruby:master Nov 29, 2015
@xaviershay
Copy link
Collaborator

Added some method documentation and merged. Thank you! I'll include this in 0.11.

@xaviershay xaviershay mentioned this pull request Nov 29, 2015
jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Dec 2, 2015
0.11.0 2015-11-29 ([changes](simplecov-ruby/simplecov@v0.10.0...v0.10.11))
=================

## Enhancements

* Added `SimpleCov.minimum_coverage_by_file` for per-file coverage thresholds. See [#392](simplecov-ruby/simplecov#392) (thanks @ptashman)
* Added `track_files` configuration option to specify a glob to always include in coverage results, whether or not those files are required. See [#422](simplecov-ruby/simplecov#422) (thanks @hugopeixoto)
* Speed up `root_filter` by an order of magnitude. See [#396](simplecov-ruby/simplecov#396) (thanks @raszi)

## Bugfixes

* Fix warning about global variable `$ERROR_INFO`. See [#400](simplecov-ruby/simplecov#400) (thanks @amatsuda)
* Actually recurse upward looking for `.simplecov`, as claimed by the documentation, rather than only the working directory. See [#423](simplecov-ruby/simplecov#423) (thanks @alexdowad)
@andyw8
Copy link
Contributor

andyw8 commented May 10, 2017

This seems a really useful feature for finding unused code – worth highlighting in the README?

@ghost
Copy link

ghost commented May 24, 2018

Hi @andyw8

This seems a really useful feature for finding unused code
How so?

@PragTob
Copy link
Collaborator

PragTob commented May 24, 2018

@ClaudioCarmeli I think he meant because it finds even files that aren't even required --> those can probably be deleted or something in the setup is wrong/incomplete

@andyw8
Copy link
Contributor

andyw8 commented May 24, 2018

Yes, that's what I was thinking of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants