0.3.2 issue with parsing xml
Asked by Frederik Mann:

Greetings,

something changed between 0.3.1 -\> 0.3.1 when parsing a report's xml.

The pmd report was with version pmd 1.30 with the paramters "--format xslt --property xsltFilename=pmd/pmd-to-checkstyle.xsl --rulesets pmd/coe_pmd_ruleset.xml -language apex --report-file pmd/pmd-result.xml --fail-on-violation false".

```
SEVERE: Error when parsing /opt/atlassian/pipelines/agent/build/pmd-result.xml as se.bjurr.violations.lib.parsers.CheckStyleParser content:
<?xml version="1.0" encoding="UTF-8"?>
<file xmlns:pmd="http://pmd.sourceforge.net/report/2.0.0"
name="/opt/atlassian/pipelines/agent/build/force-app/main/default/classes/arlanisUtilities/ClsRecordTypeUtil.cls">
<error line="22" column="38" severity="info"
message="Missing or mismatched ApexDoc @param"
source="https://pmd.github.io/pmd-6.49.0/pmd_rules_apex_documentation.html#apexdoc"/>
<error line="134" column="30" severity="info" message="Missing ApexDoc comment"
source="https://pmd.github.io/pmd-6.49.0/pmd_rules_apex_documentation.html#apexdoc"/>
<error line="141" column="30" severity="info" message="Missing ApexDoc comment"
source="https://pmd.github.io/pmd-6.49.0/pmd_rules_apex_documentation.html#apexdoc"/>
<error line="152" column="30" severity="info" message="Missing ApexDoc comment"
source="https://pmd.github.io/pmd-6.49.0/pmd_rules_apex_documentation.html#apexdoc"/>
<error line="173" column="30" severity="info"
message="Missing or mismatched ApexDoc @param"
source="https://pmd.github.io/pmd-6.49.0/pmd_rules_apex_documentation.html#apexdoc"/>
</file>
<file xmlns:pmd="http://pmd.sourceforge.net/report/2.0.0"
name="/opt/atlassian/pipelines/agent/build/force-app/main/default/classes/arlanisUtilities/ClsRecordTypeUtil_Test.cls">
<error line="63" column="10" severity="info"
message="'System.assertEquals' should have 3 parameters."
source="https://pmd.github.io/pmd-6.49.0/pmd_rules_apex_bestpractices.html#apexassertionsshouldincludemessage"/>
<error line="73" column="10" severity="info"
message="'System.assertEquals' should have 3 parameters."
source="https://pmd.github.io/pmd-6.49.0/pmd_rules_apex_bestpractices.html#apexassertionsshouldincludemessage"/>
<error line="76" column="10" severity="info"
message="'System.assertEquals' should have 3 parameters."
source="https://pmd.github.io/pmd-6.49.0/pmd_rules_apex_bestpractices.html#apexassertionsshouldincludemessage"/>
<error line="79" column="10" severity="info"
message="'System.assertEquals' should have 3 parameters."
source="https://pmd.github.io/pmd-6.49.0/pmd_rules_apex_bestpractices.html#apexassertionsshouldincludemessage"/>
</file>

...more rules...


javax.xml.stream.XMLStreamException: ParseError at [row,col]:[17,2]
Message: The markup in the document following the root element must be well-formed.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:604)
at se.bjurr.violations.lib.parsers.CheckStyleParser.parseReportOutput(CheckStyleParser.java:41)
at se.bjurr.violations.lib.reports.ViolationsFinder.findViolations(ViolationsFinder.java:35)
at se.bjurr.violations.lib.ViolationsApi.violations(ViolationsApi.java:103)
at com.atlassian.bitbucket.pipelines.checkstyle.report.Main.main(Main.java:99)
```

I think XML was not enforced before to be well-formed and it might be an issue with our pmd-to-checkstyle.xsl.


Answers:
author: Frederik Mann
body: The issue was with the report.xml. It was missing a starting and enclosing tag.


author: Igor Stoyanov
body: [@Frederik Mann](/t5/user/viewprofilepage/user-id/4001997) hi. Can you confirm that all works on checkstyle-report 0.3.1 but not in version 0.3.2? We bumped violations lib from version 1.116 to 1.149  

Regards, Igor.

comments: author: Frederik Mann
body: Hi [@Igor Stoyanov](/t5/user/viewprofilepage/user-id/4550492) , yes I can confirm that everything works when switching back from 0.3.2 to 0.3.1.

The very same report, then can be evaluated by checkstyle-report and is shown in the pipeline with results.


Tags: bitbucket-cloud

bitbucket-pipelines

cloud