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

phpcs-changed is checking all the files when empty file is provided #9

Closed david-binda closed 5 years ago

david-binda commented 5 years ago

In my testing, I've run into an issue with an empty file, as the cat empty.file | phpcs --report=json seems to be instructing the phpcs to read all local files and directories. By using the - flag, described in help as

  -     Check STDIN instead of local files and directories

seems to fix the issue.

The issue can be reproduced even with phpcs itself:

~/PHP_CodeSniffer$ touch foo.php
~/PHP_CodeSniffer$ cat foo.php | phpcs --report=json
............................................................ 60 / 68 (88%)

and can be fixed by adding the - flag to the end:

$ touch foo.php
$ cat foo.php | phpcs --report=json -
E 1 / 1 (100%)

{"totals":{"errors":1,"warnings":0,"fixable":0},"files":{"STDIN":{"errors":1,"warnings":0,"messages":[{"message":"Missing file doc comment","source":"PEAR.Commenting.FileComment.Missing","severity":5,"fixable":false,"type":"ERROR","line":1,"column":1}]}}}