Reputation: 5086
Which codesniffer sniff should I use to find lines which just contain spaces? The PSR-2 standard already covers whitespace at end of non-empty lines, but I also want to cover empty lines.
Upvotes: 1
Views: 3204
Reputation: 7222
You might want to try this sniff: https://github.com/squizlabs/PHP_CodeSniffer/blob/master/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php
Include it in your ruleset.xml file using:
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
It will look for whitespace at the end of any line, start and end of a file, and multiple blank lines in a row (even if they don't contain spaces). You can mute any of those messages that you don't want by changing the severity of the error code to 0 in a ruleset.xml file. For example:
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
<severity>0</severity>
</rule>
Upvotes: 1