[PEAR-BUG] Bug #20378 [Asn->Csd]: Report appended to existing file if no errors found in run

[email protected]
Newsgroups php.pear.bugs
Message-ID <[email protected]>
Edit report at https://pear.php.net/bugs/bug.php?id=20378&edit=1

 ID:               20378
 Updated by:       [email protected]
 Reported By:      ferdypruis at gmail dot com
 Summary:          Report appended to existing file if no errors found
                    in run
-Status:           Assigned
+Status:           Closed
 Type:             Bug
 Package:          PHP_CodeSniffer
 Operating System: CentOS
 Package Version:  1.5.4
 PHP Version:      Irrelevant
 Assigned To:      squiz
 Roadmap Versions: 
 New Comment:

-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


Previous Comments:
------------------------------------------------------------------------

[2014-09-01 00:53:51] squiz

-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-08-29 10:00:36] ferdyp

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>

------------------------------------------------------------------------


-- 
Edit this bug report at https://pear.php.net/bugs/bug.php?id=20378&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.