My attempt to exclude the check for the EOL char on my Windows machine always results in this error message:
>vendor\bin\phpcs.bat --standard=PSR2 --exclude=Generic.Files.LineEndings.InvalidEOLChar src\version.php
ERROR: The specified sniff code "Generic.Files.LineEndings.InvalidEOLChar" is invalid
Run "phpcs --help" for usage information
Can't figure out what I'm doing wrong. I have installed PHP CodeSniffer via composer and am running version 3.4.0.
If PHP_CodeSniffer finds any coding standard errors, a report will be shown after running the command. Full usage information and example reports are available on the usage page. The documentation for PHP_CodeSniffer is available on the Github wiki. Bug reports and feature requests can be submitted on the Github Issue Tracker.
PHP_CodeSniffer allows developers to design their own coding standards by creating a simple ruleset XML file that both pulls in sniffs from existing standards and customises them for the developer's needs. This XML file can be named anything you like, as long as it has an xml extension and complies to the ruleset.xml format.
If you use Phive, you can install PHP_CodeSniffer as a project tool using the following commands: You will then be able to run PHP_CodeSniffer from the tools directory: PEAR. If you use PEAR, you can install PHP_CodeSniffer using the PEAR installer.
You can also download the PHP_CodeSniffer source and run the phpcs and phpcbf commands directly from the Git clone: The default coding standard used by PHP_CodeSniffer is the PEAR coding standard. To check a file against the PEAR coding standard, simply specify the file's location:
The --exclude
CLI argument accepts 3-part sniffs codes, but you've passed in a 4-part error code.
In your case, the sniff code is Generic.Files.LineEndings
and that sniff only generates a single error code, so you'll be fine ignoring the entire sniff:
vendor\bin\phpcs.bat --standard=PSR2 --exclude=Generic.Files.LineEndings src\version.php
If you want to exclude individual error codes, or if you just want to lock down a standard for your project, you'll need to use a ruleset.xml file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With