sirbrillig / phpcs-changed

🐘 Run phpcs on files and only report new warnings/errors compared to the previous version.
MIT License
31 stars 11 forks source link

Add/xml reporter #38

Closed delputnam closed 3 years ago

delputnam commented 3 years ago

This pull request adds the XML report type and the -i (to show the list of installed coding standards) to mimic these features provided by phpcs. This is useful for users who want to use phpcs-changed with an IDE like PHPStorm which requires use of the XML report type.

In order to test the XML report, specify the option --report=xml when using phpcs-changed. Ex:

❯  phpcs-changed --report=xml --git myProject/foo.php
<?xml version="1.0" encoding="UTF-8"?>
<phpcs version="3.5.8">
    <file name="/home/delputnam/projects/myProject/foo.php" errors="0" warnings="1" fixable="0">
        <warning line="21" column="2" source="VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable" severity="5" fixable="0">Unused variable $x.</warning>
    </file>
</phpcs>

To view the installed coding standards:

❯  phpcs-changed -i
The installed coding standards are PEAR, Zend, PSR2, MySource, Squiz, PSR1, PSR12, ImportDetection and VariableAnalysis

This PR also includes unit tests for the new XmlReporter class.

sirbrillig commented 3 years ago

Looks great! Thank you so much!