Skip to content

🐛 code-coverage: FileExplorer shows incorrect folder coverage percentage #6610

@nworbiii

Description

@nworbiii

Workspace

code-coverage

📜 Description

The FileExplorer component displays incorrect coverage percentages for folders. While the "Missing lines" and "Tracked lines" columns are correctly aggregated, the "Coverage" percentage is calculated as a simple average of child coverage percentages instead of being derived from the aggregated line counts.

In FileExplorer.tsx, the buildFileStructure function (lines 102-106) calculates folder coverage as a simple average of child percentages:

coverage:                                                                                                                                                                            
  dataGroupedByPath[pathGroup].reduce(                                                                                                                                               
    (acc: number, cur: CoverageTableRow) => acc + cur.coverage,                                                                                                                      
    0,                                                                                                                                                                               
  ) / dataGroupedByPath[pathGroup].length,        

This should instead calculate coverage from the aggregated missing and tracked values.

👍 Expected behavior

Folder coverage should be calculated as:
coverage = ((tracked - missing) / tracked) * 100
Using the displayed data: (2473 - 981) / 2473 = 60.33%

👎 Actual Behavior with Screenshots

The coverage shows 34.78% while the History section correctly shows 60.33%. The missing (981) and tracked (2473) line counts are correct, but the percentage doesn't match.

Image Image

👟 Reproduction steps

  1. Upload a JaCoCo (or other) coverage report for an entity
  2. Navigate to the Code Coverage tab
  3. Compare the "History" section coverage with the "Explore Files" root folder coverage

📃 Provide the context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

Are you willing to submit PR?

Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions