Skip to content

Conversation

ggilder
Copy link

@ggilder ggilder commented May 22, 2023

Per https://confluence.atlassian.com/pages/viewpage.action?pageId=79986990 which is already referenced for the calculation:

So in order to calculate the Total Percentage Coverage metric using data from an XML report you have to use the following equation:

TPC = (coveredconditionals + coveredstatements + coveredmethods) / (conditionals + statements + methods)

Using elements is incorrect because, as that page notes, "elements" is conditionals + statements, which means the previous calculation would double-count statements.

Also, the clover-format XML includes multiple metrics elements which were being redundantly counted. Each file element contains a metrics element, but then there is also a metrics element within each class defined in that file. Finally, there is a project level metrics element which summarizes all the files tested.

Therefore, we only need to pick out the project level element to get the total metrics, and the summing is not necessary. However, I've left the summing in place so that this could be extended with, for instance, a coverage check on only modified files.

Per https://confluence.atlassian.com/pages/viewpage.action?pageId=79986990 which is already referenced for the calculation:

    So in order to calculate the Total Percentage Coverage metric using data from an XML report you have to use the following equation:

    TPC = (coveredconditionals + coveredstatements + coveredmethods) / (conditionals + statements + methods)

Using elements is incorrect because, as that page notes, "elements" is
conditionals + statements, which means the previous calculation would
double-count statements.

Also, the clover-format XML includes multiple `metrics` elements which
were being redundantly counted. Each `file` element contains a
`metrics` element, but then there is also a `metrics` element within
each `class` defined in that file. Finally, there is a `project` level
`metrics` element which summarizes all the files tested.

Therefore, we only need to pick out the `project` level element to get
the total metrics, and the summing is not necessary. However, I've left
the summing in place so that this could be extended with, for instance,
a coverage check on only modified files.
@willpower232
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants