Skip to content

Conversation

@KminekMatej
Copy link
Contributor

In my project I had to manually count code coverage for further reporting. To avoid parsing the code coverage from standard HTML report I wanted to use machine-ready structure so I checked Clover XML output. I expected by dividing project->metric->coveredStatements / project->metric->statements to reach the same percents as HTML output has, but surprisingly the number was quite different.

During diving into the used algorithm I found out that Clover XML report does not take into account lines which are actually present in the file outside the class / trait scope. Even with a small todo mentioned in comments that it needs to be finished. So I tried to finish it.

During analyzation of the code, there is new function which counts the stats of the lines outside classes / traits and adds these stats into project metrics.

I believe this is smoething to be primarily checked by @milo , who (according to git blame) wrote most of the XML coverage code (big kudos 💪 ).

This PR does not fix the entire percent count completely, as the goal is to count fomr this report same percentil as is reported in the CLI Tester after the tests, but it gets it one step closer to the end.

JanTvrdik and others added 7 commits November 25, 2025 14:15
PHP 8.5 deprecated using null as an array offset. When running
`-o console` without a filename, $file was null and used as array
key in $outputFiles[$file], triggering E_DEPRECATED which the
strict error handler converted to a fatal error.

Changed the default from null to empty string '' and updated the
corresponding null checks to check for empty string instead.
These lines are correctly represented by <line> xml tag, but should be counted amongst the coverage/project/metrics, affecting statements / coveredStatements metrics
@KminekMatej
Copy link
Contributor Author

Checks are failing on issues clearly independent to my updates.

HTTPAssertTest is getting improper response from httpbin, often its just 502 HTTP response code.

Checks related to PHPDBG are failing on weird issues, but looking into history these issues sometimes occurs even on @dg or @JanTvrdik commits. I dont think fixing these checks should be part of this PR, am I right?

@dg dg force-pushed the master branch 6 times, most recently from 0f7d4b3 to bc7d56b Compare January 6, 2026 21:28
@dg dg force-pushed the master branch 10 times, most recently from 2c855ca to 0bc552e Compare January 7, 2026 12:26
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.

Work with lines outside class/struct in Clover XML report

3 participants