Skip to content

Change generated Clover XML to validate against Clover XSD #1079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sebastianbergmann opened this issue May 20, 2025 · 9 comments
Closed

Change generated Clover XML to validate against Clover XSD #1079

sebastianbergmann opened this issue May 20, 2025 · 9 comments

Comments

@sebastianbergmann
Copy link
Owner

It would help me if somebody could look into whether https://bitbucket.org/atlassian/clover/raw/master/etc/schema/clover.xsd is, in fact, the official/canonical schema for Clover XML and, if it is, look into whether there are any other changes PHPUnit (or phpunit/php-code-coverage, rather) needs to implement to comply with the schema.

Originally posted by @sebastianbergmann in sebastianbergmann/phpunit#6210 (comment)

@ravage84
Copy link

Today, if we speak about Clover which was from Atlassian and hosted on BitBucket, we should speak about OpenClover, its open source successor, which is hosted on GitHub.

OpenClover is a free and open-source successor of Atlassian Clover, created as a fork from the Clover code base published by Atlassian in 2017.

https://en.wikipedia.org/wiki/Java_code_coverage_tools#OpenClover

The official OpenClover Website:
https://openclover.org/

Latest OpenClover as of 2025-05-20 is verion 4.5.2:

https://openclover.org/downloads
https://openclover.org/doc/manual/latest/idea--overview.html

Link from official OpenClover blog, a post about the newest release, to changes on GitHub.

We're thrilled to share with you next version of OpenClover. In this release we've implemented support for Java 14 switch expressions. I must admit this was not a small task, just have a look at the sheer amount of changes required.

https://openclover.org/blog

Link from the official OpenClover website to the offical issue tracker on GitHub:

OpenClover issues

https://openclover.org/documentation

In that GitHub repo one can find the clover.xsd, the sole XSD by the way, which is idential with the one you linked to on BitBucket:

https://github.com/openclover/clover/blob/openclover-4.5.2/clover-core/src/main/resources/clover.xsd

Unfortunately, I haven't found any official statement whether this file is actually the "official/canonical schema for (Open)Clover XML".

@sebastianbergmann
Copy link
Owner Author

@ravage84 Thank you!

@marcphilipp Do you have any insights? Thanks in advance!

@ravage84
Copy link

Using the online XML validator on https://www.freeformatter.com/xml-validator-xsd.html with

  • coverage reports in clover format generated with PHPUnit 8.5 from two of our applications
  • and the clover.xsd we found,

I could not successfully verify the produced coverage report.
It showed me several validation errors.

Some anonymized examples:

Cvc-complex-type.4: Attribute 'clover' Must Appear On Element 'coverage'., Line '1', Column '34'.
Cvc-complex-type.2.4.a: Invalid Content Was Found Starting With Element 'package'. One Of '{metrics}' Is Expected., Line '3', Column '43'.
Cvc-complex-type.2.4.a: Invalid Content Was Found Starting With Element 'file'. One Of '{metrics}' Is Expected., Line '4', Column '111'.
Cvc-datatype-valid.1.2.1: 'C:\[SNIP].php' Is Not A Valid Value For 'NCName'., Line '4', Column '111'.
Attribute 'name' On Element 'file' Is Not Valid With Respect To Its Type, 'NCName'., Line '4', Column '111'.
Cvc-complex-type.4: Attribute 'path' Must Appear On Element 'file'., Line '4', Column '111'.
Cvc-complex-type.2.4.a: Invalid Content Was Found Starting With Element 'class'. One Of '{metrics}' Is Expected., Line '5', Column '107'.
Cvc-attribute.3: The Value '[NAMESPACE] 'name' On Element 'package' Is Not Valid With Respect To Its Type, 'NCName'., Line '11', Column '60'.
Cvc-complex-type.2.4.a: Invalid Content Was Found Starting With Element 'file'. One Of '{metrics}' Is Expected., Line '12', Column '130'.
Cvc-complex-type.3.2.2: Attribute 'name' Is Not Allowed To Appear In Element 'line'., Line '22', Column '111'.
Cvc-complex-type.3.2.2: Attribute 'crap' Is Not Allowed To Appear In Element 'line'., Line '22', Column '111'.

@ravage84
Copy link

This is mostly a duplicate of issue #578

@ravage84
Copy link

Also, I can confirm @amottier's observation about splitting the absolute file path into the attributes name and path.

Confirming statement of the author of the Jenkins Coverage plugin about a related UX issue:

From https://github.com/openclover/clover/blob/fc5760c44ac4c6fd7a77fbe804ad26b12b231bb9/clover-core/src/main/resources/clover.xsd#L69 the file element should contain a name and path element. PHP[Unit] just uses the name attribute.

(Formatting by myself)

@marcphilipp
Copy link

@marcphilipp Do you have any insights? Thanks in advance!

I'm afraid I don't. Sorry!

@sebastianbergmann
Copy link
Owner Author

@marcphilipp Do you have any insights? Thanks in advance!

I'm afraid I don't. Sorry!

No worries, thank you for responding.

@sebastianbergmann
Copy link
Owner Author

Any help with #1080 would be much appreciated. As a first step, I have expanded the tests for the Cover XML reporter to validate the generated XML against Clover's XSD.

@sebastianbergmann sebastianbergmann changed the title Investigate whether the generated Clover XML validates against Clover's XSD Change generated Clover XML to validate against Clover XSD May 21, 2025
@sebastianbergmann
Copy link
Owner Author

Discussion moved to #1080.

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

No branches or pull requests

3 participants