[buddypress-trac] [BuddyPress Trac] #7228: Add PHPCS

buddypress-trac noreply at wordpress.org
Mon Apr 9 03:19:06 UTC 2018


#7228: Add PHPCS
------------------------------+-------------------------------------
 Reporter:  DJPaul            |       Owner:  (none)
     Type:  enhancement       |      Status:  reopened
 Priority:  normal            |   Milestone:  Awaiting Contributions
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:                    |
------------------------------+-------------------------------------
Description changed by netweb:

Old description:

> In order to help ensure a baseline quality of new code contributions and
> changes, I'm suggesting we think about adopting PHP Code Sniffer (PHPCS).
>
>  PHP_CodeSniffer is a PHP script that tokenises and "sniffs" PHP... to
> detect violations of a defined coding standard. It is an essential
> development tool that ensures your code remains clean and consistent. It
> can also help prevent some common semantic errors made by developers.
>
> There are pretty good (though not perfect) WordPress-specific "sniffs" at
> https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
>
> In a perfect world, we would have these as a pre-commit hook so
> Committers don't get lazy, but initially, I assume they'd be hooked up as
> a Grunt task. I also imagine we'd run with a very minimal set of sniffs
> so we don't annoy everyone with trivial stuff until we get used to it
> and/or we all see the value.
>
> Probably the biggest issue is having these code sniffs only report issues
> with new/changed code, not existing code (our older code is generally not
> up to the standards of our more recent code), but there are some
> solutions for this, especially if operating on a Git checkout (see
> https://github.com/xwp/wp-dev-lib/) though there might be something we
> can do for SVN checkouts as well.
>
> What do people think?

New description:

 In order to help ensure a baseline quality of new code contributions and
 changes, I'm suggesting we think about adopting PHP Code Sniffer (PHPCS).

  PHP_CodeSniffer is a PHP script that tokenises and "sniffs" PHP... to
 detect violations of a defined coding standard. It is an essential
 development tool that ensures your code remains clean and consistent. It
 can also help prevent some common semantic errors made by developers.

 There are pretty good (though not perfect) WordPress-specific "sniffs" at
 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards

 In a perfect world, we would have these as a pre-commit hook so Committers
 don't get lazy, but initially, I assume they'd be hooked up as a Grunt
 task. I also imagine we'd run with a very minimal set of sniffs so we
 don't annoy everyone with trivial stuff until we get used to it and/or we
 all see the value.

 Probably the biggest issue is having these code sniffs only report issues
 with new/changed code, not existing code (our older code is generally not
 up to the standards of our more recent code), but there are some solutions
 for this, especially if operating on a Git checkout (see
 https://github.com/xwp/wp-dev-lib/) though there might be something we can
 do for SVN checkouts as well.

 What do people think?

 See also :#WP41057

--

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/7228#comment:11>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list