Skip to content

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

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.

Activity

  1. tamesuu commented on Jan 15, 2023

    @tamesuu

    @PragTob
    Hello!

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

  2. added a commit that references this issue on Apr 4, 2026
    c27a0b2
  3. added theissue type on May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions