awesomemotive / easy-digital-downloads

Sell digital downloads through WordPress
https://easydigitaldownloads.com
GNU General Public License v2.0
864 stars 475 forks source link

Implement WordPress Coding Standards for PHP #6905

Open spencerfinnell opened 6 years ago

spencerfinnell commented 6 years ago

Now that WordPress Coding Standards for PHP have reached a 1.0 release I think it would be as good of time as any to implement these rules.

https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards

Implementing the standards could be done in a few ways:

  1. Setup the standards and run automatic fixes allowing as many immediate code standards updates as possible. As things change in files moving forwards their file should be updated to fix any coding standards that could not be automatically fixed. I'm pretty sure this is what core did.

For reference I ran the standards on the codebase and it touched ~393 files with automatic fixes.

  1. Only enforce standards moving forward leaving the current codebase untouched until something changes.

The automatic fixes are almost entirely spacing issues that can't break anything. The biggest debate currently is multiline function arguments: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1330

cklosowski commented 6 years ago

@spencerfinnell Can we get our .editorconfig updated for any necessary changes?

spencerfinnell commented 6 years ago

@cklosowski the .editorconfig looks pretty much up to date as far as I know.

https://github.com/WordPress/gutenberg/blob/master/.editorconfig is the newest I'm aware of.

spencerfinnell commented 6 years ago

Pushed a branch with the auto fixes to get an idea of what would change: https://github.com/easydigitaldownloads/easy-digital-downloads/compare/release/3.0...phpcs

Ruleset: https://github.com/easydigitaldownloads/easy-digital-downloads/blob/6ba923af3435367132605668fb2082fa91cb4515/phpcs.xml

spencerfinnell commented 6 years ago

The *template*.php-type files that include a lot of inline conditionals would need to be manually refactored to avoid some ugly spacing (and probably some other general manual cleanup).