Skip to content

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

Open
@PragTob

Description

@PragTob

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions