1

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.

white_gecko
  • 4,808
  • 4
  • 55
  • 76

1 Answers1

1

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>
Greg Sherwood
  • 6,992
  • 2
  • 29
  • 24
  • Thank you. `SuperfluousWhitespace` didn't work for be before due to an incompatibility with PSR2: https://github.com/squizlabs/PHP_CodeSniffer/issues/600 – white_gecko May 23 '15 at 12:34