WebDevStudios / custom-post-type-ui

Admin UI settings for creating custom post types and taxonomies in WordPress
https://webdevstudios.com
GNU General Public License v2.0
627 stars 143 forks source link

Add PHP_CodeSniffer checks #661

Closed GaryJones closed 6 years ago

GaryJones commented 7 years ago

Currently

There doesn't appear to be any code standards checks (just some for documentation).

Issue

While not critical to the plugin behaviour, it can make maintenance easier if others contribute.

Suggestion

    "require-dev": {
        "dealerdirect/phpcodesniffer-composer-installer": "^0.4",
        "sirbrillig/phpcs-variable-analysis": "^2.0",
        "wimg/php-compatibility": "dev-master",
        "wp-coding-standards/wpcs": "dev-develop"
    },

By adding something like the above packages to require-dev in composer.json, coding standards can be checked. You'd then need a customised phpcs.xml.dist (like this one) that is specific to this plugin.

What is the minimum version of PHP that is tested for? If the main plugin file is PHP 5.2, but the rest of the plugin is later, then you can still test compatibility by using something like this composer script to run phpcs.

Running these checks can then be included in the .travis.yml file as well.

tw2113 commented 6 years ago

As a whole, at the moment, i'm pretty sure our composer usage is subpar at best, and I want/need to get more familiar with the topic as a whole before I start committing too much here.

GaryJones commented 6 years ago

I'm happy to do a first pass PR for adding these checks in. The config can then be adjusted to suit, and then steps taken to fix any CS violations.