kyle-jennings / benjamin

A WordPress theme built with _s, 18f's US web design standards, and the needs of the people.
GNU General Public License v2.0
41 stars 10 forks source link

Clean up code to Standards using consolidation of WP and PHP PSR standards #23

Closed kyle-jennings closed 5 years ago

kyle-jennings commented 6 years ago

@miklb brought up the importance of using the WP Coding standards, which in turn forced me to look at my code in horror and realize that I need to clean things up.

I don't really like the WP coding standards (gross for example, are Yoda conditions ), and would prefer to use the PHP PSR standards. We can use phpcs.ruleset.xml to override WP Coding Standards we don't like. Lets use this issue to determine what we do and dont like.

kyle-jennings commented 6 years ago

From WordPress, I do not like:

I'm up in the air about:

miklb commented 6 years ago

Might be easier to skip the WP ruleset and create a custom file.

https://github.com/squizlabs/PHP_CodeSniffer/blob/master/src/Standards/PSR2/ruleset.xml

https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml

Even if just the default psr2 rules, anyone using CodeSniffer should pick up that file to override any default rules they are using. Then you can add rules as you see fit.

Conversely, it's pretty easy to remove the WP rules you don't like, i.e. <exclude name="WordPress.VIP.AdminBarRemoval.RemovalDetected" />

kyle-jennings commented 6 years ago

@miklb I've decided just to go with the PSR standards. I'm slowly going through each file and formatting things as I add features and fix bugs.

miklb commented 6 years ago

Awesome. I'm about to revisit the project I've been working using your tools, so will see what/where I can contribute. Thanks for addressing this.

miklb commented 5 years ago

would this default ruleset work for you along with an .editorconfig to normalize tabs & space?

miklb commented 5 years ago

I see latest commit addresses this with a phpcs.ruleset.xml file. thanks 🎉

kyle-jennings commented 5 years ago

Finally getting around to this. After reflecting, I decided to use the WordPress code standards and have updated the phpcs ruleset to use the which include Core, Docs, and Extra as documented here: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards

@miklb checkout this branch: https://github.com/kyle-jennings/benjamin/tree/wpcs

I need to double and triple check everything but I'm hoping to merge that into dev and master soon