php-code-coverage icon indicating copy to clipboard operation
php-code-coverage copied to clipboard

Crap4J: Unparseable number: "" for

Open bouzikas opened this issue 11 years ago • 0 comments

Hi,

When building my project with Jenkins, I'm getting this error in Crap4j:

[CRAP4J] Collecting Crap4J analysis files...
[CRAP4J] Searching for report files within build/logs/crap4j.xml
[CRAP4J] Using the new FileSetBuilder
ERROR: Build step failed with exception
java.lang.NumberFormatException: Unparseable number: "" for....
.......
Build step 'Report Crap' marked build as failure.

and the build fails. After an investigation on this, I realize that the problem is in php-code-coverage.

The report file of crap4j (build/logs/crap4j.xml) using phpunit 4.7.5 for the property "crapMethodPercent" is extracting:

<crapMethodPercent>0<crapMethodPercent/>

which is correct and the Crap4j plugin is parsing the file successfully.

but phpunit 4.7.6 and above is extracting:

<crapMethodPercent/>

Example file:

<?xml version="1.0" encoding="UTF-8"?>
<crap_result>
  <project/>
  <timestamp>2015-09-11 17:13:40</timestamp>
  <stats>
    <name>Method Crap Stats</name>
    <methodCount>0</methodCount>
    <crapMethodCount>0</crapMethodCount>
    <crapLoad>0</crapLoad>
    <totalCrap>0</totalCrap>
    <crapMethodPercent/>
  </stats>
  <methods/>
</crap_result>

which causing the Crap4J plugin unable to parse the file. So it fails with the error mention above.

The code in phpunit.phar-4.7.6 causing the problem:

if ($fullMethodCount > 0) {
    $crapMethodPercent = $this->roundValue((100 * $fullCrapMethodCount) / $fullMethodCount);
} else {
    $crapMethodPercent = '';
}

$stats->appendChild($document->createElement('crapMethodPercent', $crapMethodPercent));

Thanks in advance

bouzikas avatar Sep 14 '15 06:09 bouzikas