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

svn: Uncaught Exception when running on newly added file #5

Closed sirbrillig closed 5 years ago

sirbrillig commented 5 years ago

Instructions to reproduce:

touch foo.php
svn add foo.php
phpcs-changed --svn foo.php
PHP Fatal error:  Uncaught Exception: Failed to decode phpcs JSON: 'ERROR: You must supply at least one file or directory to process.
sirbrillig commented 5 years ago

With debug output on the repo where the error occurs:

Running...
validating executables
executables are valid
checking svn existence of file with command:
svn info 'foo.php'
svn status output:
Path: foo.php
Name: foo.php
Working Copy Root Path: /home/repo
URL: https://repo/trunk/foo.php
Relative URL: ^/trunk/foo.php
Repository Root: https://repo
Repository UUID: XXX
Node Kind: file
Schedule: add

running diff command:
svn diff 'foo.php'
diff command output:
Index: foo.php
===================================================================

Property changes on: foo.php
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property

checking svn status of file with command:
svn info 'foo.php'
svn status output:
Path: foo.php
Name: foo.php
Working Copy Root Path: /home/repo
URL: https://repo/trunk/foo.php
Relative URL: ^/trunk/foo.php
Repository Root: https://repo
Repository UUID: XXX
Node Kind: file
Schedule: add

running new phpcs command:
cat 'foo.php' | phpcs --report=json --standard='phpcs.xml'
new phpcs command output:
ERROR: You must supply at least one file or directory to process.

Run "phpcs --help" for usage information
sirbrillig commented 5 years ago

This is happening because if the file is empty, there is nothing to run through phpcs.