Skip to content

Preserve empty IClassCoverage nodes in CoverageBuilder and in XML report #806

@ghost

Description

Hey all,

Integrations that consume XML reports are unable to distinguish between two reasons of classes and sources absence in the report

  • does not contain executable lines (e.g. Java interfaces without default methods) or was filtered out (e.g. marked with @Generated annotation)
  • was not analyzed at all

and therefore cannot inform user about last one.

This happens because of

https://github.com/jacoco/jacoco/blob/v0.8.2/org.jacoco.core/src/org/jacoco/core/analysis/CoverageBuilder.java#L101-L102

which was added a long time ago in version 0.3.2 by

e47d22d


This is exactly what happens with both SonarQube integrations (one that reads XML and another that reads exec-file) - #797 : in absence of information for source file (in XML report in first case, CoverageBuilder in second), SonarQube assumes that it was not executed/analyzed and tries to estimate from syntax tree of source file its missed coverage, and this estimation is not consistent with filtering of @Generated by JaCoCo.


There are some workarounds for integrations that read exec-file - e.g. custom ICoverageVisitor that will track IClassCoverage.getSourceFileName() prior delegation to CoverageBuilder.

However there are doesn't seem to be any option for integrations that read only XML reports.


Could you please (re)consider preservation of empty IClassCoverage nodes in CoverageBuilder and in XML report, and skip them only when generating HTML ?

Cheers,
Michael

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions