Skip to content

Commit

Permalink
Composer: require the DealerDirect plugin
Browse files Browse the repository at this point in the history
As VIPCS requires two external standards, including the new `VariableAnalysis` dependency, let's require the DealerDirect plugin to make life easier on people who install via Composer.

Includes updating the Readme to mention the `VariableAnalysis` standard, as well as mention that the DealerDirect plugin is now a project requirement.

Note: I've widened the version constraints for the DealerDirect plugin to prevent conflicts with customer projects which already required the plugin, but potentially at a different version.
The version constraints now set cover all released versions which support external standards properly.
  • Loading branch information
jrfnl committed Sep 14, 2020
1 parent 05789f8 commit 12f2c9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This project contains two rulesets:

These rulesets contain only the rules which are considered to be "errors" and "warnings" according to the [WordPress VIP Go documentation](https://wpvip.com/documentation/vip-go/code-review-blockers-warnings-notices/)

The rulesets use rules from the [WordPress Coding Standards](https://github.com/WordPress/WordPress-Coding-Standards) (WPCS) project.
The rulesets use rules from the [WordPress Coding Standards](https://github.com/WordPress/WordPress-Coding-Standards) (WPCS) project, as well as the [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis) standard.

Go to https://wpvip.com/documentation/phpcs-review-feedback/ to learn about why violations are flagged as errors vs warnings and what the levels mean.

Expand All @@ -18,20 +18,17 @@ Go to https://wpvip.com/documentation/phpcs-review-feedback/ to learn about why
* PHP 5.4+
* [PHPCS 3.5.5+](https://github.com/squizlabs/PHP_CodeSniffer/releases)
* [WPCS 2.3.0+](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/releases)
* [VariableAnalysis 2.8.3+](https://github.com/sirbrillig/phpcs-variable-analysis/releases)

## Installation

`composer require automattic/vipwpcs`, or `composer g require automattic/vipwpcs` if installing globally.

This will install the latest compatible versions of PHPCS and WPCS.
This will install the latest compatible versions of PHPCS, WPCS and VariableAnalysis and register the external standards with PHP_CodeSniffer.

Please refer to the [installation instructions for installing PHP_CodeSniffer for WordPress.com VIP](https://wpvip.com/documentation/how-to-install-php-code-sniffer-for-wordpress-com-vip/) for more details.

We recommend the [PHP_CodeSniffer Standards Composer Installer Plugin](https://github.com/Dealerdirect/phpcodesniffer-composer-installer), 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.

Alternatively, you should register the standard to PHPCS by appending the VIPCS directory to the end of the installed paths. e.g.

`phpcs --config-set installed_paths /path/to/wpcsstandard,path/to/vipcsstandard`
As of VIPCS version 2.3.0, there is no need to `require` the [PHP_CodeSniffer Standards Composer Installer Plugin](https://github.com/Dealerdirect/phpcodesniffer-composer-installer) anymore as it is now a requirement of VIPCS itself.

## Contribution

Expand Down
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,15 @@
],
"require": {
"php": ">=5.4",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7",
"sirbrillig/phpcs-variable-analysis": "^2.8.3",
"squizlabs/php_codesniffer": "^3.5.5",
"wp-coding-standards/wpcs": "^2.3"
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7",
"phpcompatibility/php-compatibility": "^9",
"phpunit/phpunit": "^4 || ^5 || ^6 || ^7"
},
"suggest": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will manage the PHPCS 'installed_paths' automatically."
},
"scripts": {
"install-codestandards": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run",
"ruleset": "bin/ruleset-tests",
Expand Down

0 comments on commit 12f2c9b

Please sign in to comment.