SonarCloud code coverage is reporting new lines at the end of files as uncovered with reports generated by the latest version of PHPUnit.
Newer XML reports include the new line at end of file, e.g.:
<line num="32" type="stmt" count="0"/>
I initially thought this was problem with the XML report we upload, but the issue I raised relating to this has been closed by the maintainer:
opened 01:52AM - 21 Aug 20 UTC
closed 04:27PM - 28 Aug 20 UTC
| Q | A
| --------------------------| ---------------
… | php-code-coverage version | 9.1.4
| PHP version | 7.4
| Driver | Xdebug
| Xdebug version | 2.9.6
| Installation Method | Composer
| Usage Method | PHPUnit
| PHPUnit version | 9.3.7
Since upgrading from PHPUnit `9.2`, new lines at the end of files are being reported as uncovered in the XML report, e.g.
```
<line num="32" type="stmt" count="0"/>
```
It seems to be caused by the removal of this workaround (as reinstating it fixes the clover report): https://github.com/sebastianbergmann/php-code-coverage/commit/d9c9b7b62bbfdd2c503f96fc3af831b8a8cba191
The report is being consumed by SonarCloud - should the last line of files be ignored regardless of the uploaded XML report? If that's the case, I can raise an issue with SonarCloud.
Please can you advise how we resolve this?
Hello @davidgrayston and welcome to the community,
Thanks for reaching us.
We are looking into it and will get back to you soon.
Best,
Nils
1 Like
This is how a file (that used to have 100% coverage) displays on SonarCloud:
With 1
“Uncovered Lines on New Code”
1 Like
I’ve replied to the closed issue https://github.com/sebastianbergmann/php-code-coverage/issues/799#issuecomment-678280989 as it appears the line is covered when processUncoveredFiles=“false”
I don’t think they will reply to the closed issue, so I might need to open a new one, but I won’t do so until you confirm where you think this needs to be resolved.
https://github.com/sebastianbergmann/php-code-coverage/issues/799 has been reopened, which means the XML report will likely be fixed and resolve this issue
1 Like
Hi @davidgrayston ,
thanks for keeping us up to date.
If the problem persists on our site, just contact us again,
otherwise, I would ask you to mark this thread as resolved.
Best,
Nils
system
(system)
Closed
August 31, 2020, 7:20am
7
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.