automattic/vipwpcs

PHP_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions

Installs: 27 030

Dependents: 16

Suggesters: 0

Stars: 69

Watchers: 9

Forks: 14

Open Issues: 46

Type:phpcodesniffer-standard

1.0.0 2019-04-24 21:34 UTC

README

This project maintains the minimum ruleset of PHP_CodeSniffer rules (sniffs) to validate code developed for WordPress.com VIP.

This project contains 2 PHP Codesniffer rulesets:

  • WordPressVIPMinimum - for use on WordPress.com projects
  • WordPress-VIP-Go - for use on VIP Go projects

These rulesets contain only the rules which are considered being "blockers" and "warnings" according to the WordPress VIP Go documentation

The ruleset takes advantage of existing rules in the WordPress-Coding-Standards project.

Go to https://vip.wordpress.com/documentation/phpcs-review-feedback/ to learn about why various things are flagged as errors vs warnings and what the levels mean for us.

Installation

Note

Currently, the VIP Go Coding Standards are built on top of the WordPress Coding Standards 1.* release. If you are using master here, you will need to checkout 1.2.1 tag.

First, make sure you have WPCS 1.* and PHPCS v3+ installed. If you do not, please refer to the installation instructions for installing PHP CodeSniffer for WordPress.com VIP. Note that VIPCS does not currently work with the develop or master branch of WPCS.

You will also find additional information at the WordPress Coding Standards for PHP_CodeSniffer project.

Then, clone this repo to your local machine, and add the standard to PHPCodeSniffer by appending the folder you cloned into to the end of the installed paths. e.g.

phpcs --config-set installed_paths [/path/to/wpcsstandard],[path/to/vipcsstandard],etc

Alternatively, we recommend the PHP_CodeSniffer Standards Composer Installer Plugin, which handles the registration of all of the installed standards, so there is no need to set the installed_paths config value manually, for single or multiple standards.

Minimal requirements

Setup note

Should you wish to run both standards (WordPress.com VIP minimum standard & WordPress.com VIP coding standard), you can add both to PHPCS by running the following configuration command:

phpcs --config-set installed_paths [/path/to/standard],[path/to/standard]

Note the comma separating each standard.