PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines should look outside of functions

Open polybuildr opened this issue 8 years ago • 5 comments

Currently, Squiz.WhiteSpace.SuperfluousWhitespace only looks inside functions for EmptyLines, but aren't multiple empty lines a concern even outside of functions?

The MediaWiki codesniffer standard recently had this implemented as a custom sniff (https://github.com/wikimedia/mediawiki-tools-codesniffer/commit/3a6709be2612fad63b9e9ead4e6644c28748edcc), and we were wondering if it could be upstreamed.

polybuildr avatar Jan 06 '16 20:01 polybuildr

This is checked indirectly by other sniffs, that require N lines (defaults to 1) to be between methods in a class.

aik099 avatar Jan 06 '16 21:01 aik099

+1 on this one. It''s working only in methods.

Right now it can be used as:

<ruleset ...>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines"/>
</ruleset>

You would expect it to work in a context of a class.

MediaWiki sniff linked above works like a charm.

jkobus avatar Nov 27 '17 11:11 jkobus

This is checked indirectly by other sniffs, that require N lines (defaults to 1) to be between methods in a class.

There is missing checks since there is no check between constants or comments for example.

VincentLanglet avatar Jan 04 '20 00:01 VincentLanglet

This is checked indirectly by other sniffs, that require N lines (defaults to 1) to be between methods in a class.

Thanks, do you remember which sniff is it?

Luc45 avatar Jul 01 '21 21:07 Luc45

Any update here? I'd rather not bug my team about this and not all IDEs handle this automatically.

LasseRafn avatar Feb 08 '22 19:02 LasseRafn