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

Don't mark non required files as "100%" branch coverage #902

Open
PragTob opened this issue Jul 5, 2020 · 1 comment
Open

Don't mark non required files as "100%" branch coverage #902

PragTob opened this issue Jul 5, 2020 · 1 comment
Labels
Branch Coverage Feature good first issue Good first issue to pick up if you wanna go and contribute!

Comments

@PragTob
Copy link
Collaborator

PragTob commented Jul 5, 2020

We have a problem: if files aren't loaded/required we don't have branch data. If they are added through track_files we give it 0/0 branches which we show as 100% coverage (all possible branches are covered).

That math is "wrong" though here because there are branches but we don't know what they are. We should probably count total branches here as "unkown" and establish that in our "math universe" 0/unknown = 0%. We know that none of them is covered because no one even loaded the file(s).


The not required files are added here:

simplecov/lib/simplecov.rb

Lines 366 to 376 in c8a4285

def add_not_loaded_files(result)
if tracked_files
result = result.dup
Dir[tracked_files].each do |file|
absolute_path = File.expand_path(file)
result[absolute_path] ||= SimulateCoverage.call(absolute_path)
end
end
result
end

We could potentially let a source file know that it was "force loaded" or something like that. That'd make it easier to show coverage as "unknown" and to help further distinguish these cases.

@PragTob PragTob added the Feature label Jul 5, 2020
@PragTob PragTob added Branch Coverage good first issue Good first issue to pick up if you wanna go and contribute! labels Aug 16, 2020
@tamesuu
Copy link

tamesuu commented Jan 15, 2023

@PragTob
Hello!

Is this issue active??
I wanto try this issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Branch Coverage Feature good first issue Good first issue to pick up if you wanna go and contribute!
Projects
None yet
Development

No branches or pull requests

2 participants