Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Bug #20378 Report appended to existing file if no errors found in run
Submitted: 2014-08-29 14:00 UTC
From: ferdyp Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version 1.5.4)
PHP Version: Irrelevant OS: CentOS
Roadmaps: (Not assigned)    
Subscription  


 [2014-08-29 14:00 UTC] ferdyp (Ferdy Pruis)
Description: ------------ When using the checkstyle-format and writing to a report-file, each run no errors are found a new report is nested inside the existing report, resulting in invalid XML. I ran into this problem while using Jenkins, which fails to parse the XML report for all projects that lack codestyle-errors. Test script: --------------- Run this command; phpcs --report=checkstyle --report-checkstyle=/tmp/phpcs/report /tmp/phpcs/example.php Where '/tmp/phpcs/example.php' is completely empty or otherwise contains no errors for the sniffs that are used. The first run the report file is ok. Each consecutive run duplicate nodes are added, corrupting the XML structure. This only occurs when not a single error or warning is found, checkstyle formatting is used, and a previous report file already exists. Expected result: ---------------- /tmp/phpcs/report: <?xml version="1.0" encoding="UTF-8"?> <checkstyle version="1.5.4"> </checkstyle> Actual result: -------------- /tmp/phpcs/report: <?xml version="1.0" encoding="UTF-8"?> <checkstyle version="1.5.4"> <?xml version="1.0" encoding="UTF-8"?> <checkstyle version="1.5.4"> </checkstyle> </checkstyle>

Comments

 [2014-09-01 04:53 UTC] squiz (Greg Sherwood)
-Summary: Syntax error in XML report file +Summary: Report appended to existing file if no errors found in run -Assigned To: +Assigned To: squiz
 [2014-09-01 04:55 UTC] squiz (Greg Sherwood)
-Status: Assigned +Status: Closed
This was a general error for all report types, but most notable in the ones that output some content even when nothing is found. Fix is committed here: https://github.com/squizlabs/PHP_CodeSniffer/commit/933bd158d79247993bdf6e547c 55fcdcbefa6b3e