joomla / coding-standards

Joomla Coding Standards Definition
https://developer.joomla.org/coding-standards/basic-guidelines.html
GNU General Public License v2.0
128 stars 129 forks source link

One indenting sniff to rule them all #216

Closed photodude closed 6 years ago

photodude commented 6 years ago

We have some indenting issues related to our custom sniffs See #206 let Generic.WhiteSpace.ScopeIndent do indenting, why should we do extra work for indenting when one core sniff already does the work for us.

This PR works at eliminating indent duplication in the full ruleset. Bonus Time: we get rid of some awkward custom sniff messages about space indenting.

One indenting sniff to rule them all, One indenting sniff to find them; One indenting sniff to bring them all and in the darkness fix them.

photodude commented 6 years ago

note: This works in all cases I've tested, but... in the case of having one too many tabs on an opening scope this indenting will not error. It only errors if there are too few.

I'm reporting that to PHPCS as it's occurring with open new scopes { on if tokens which I believe is one of the cases that should be an exact indent. https://github.com/squizlabs/PHP_CodeSniffer/issues/1815

Even with the issue with too many tabs, This is a better more stable solution than our custom sniff.

photodude commented 6 years ago

Closing due to the following

Generic.WhiteSpace.ScopeIndents's error code is for any indent error. Squiz.WhiteSpace.ScopeCloseBrace's error code is the closing brace indent. FunctionCallSignature's error code is for bad indents for any line in a multi-line function call. We might be able to exclude Squiz.WhiteSpace.ScopeClosingBrace if we are happy that the other sniffs are enforcing the rules we want