From 383c37b50862aeb84cbf4976578c2765b9af9133 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 19 Sep 2023 05:10:28 +0200 Subject: [PATCH 1/2] Composer: add Automattic VIP sniffs requirement --- .github/workflows/basics.yml | 3 ++- .github/workflows/quicktest.yml | 2 +- .github/workflows/test.yml | 2 +- README.md | 1 + composer.json | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/basics.yml b/.github/workflows/basics.yml index 4505996..8eb698a 100644 --- a/.github/workflows/basics.yml +++ b/.github/workflows/basics.yml @@ -49,9 +49,10 @@ jobs: squizlabs/php_codesniffer:"dev-master" phpcsstandards/phpcsutils:"dev-develop" phpcsstandards/phpcsextra:"dev-develop" - wp-coding-standards/wpcs:"dev-develop" + wp-coding-standards/wpcs:"dev-develop as 3.99" # Alias needed to prevent composer conflict with VIPCS. slevomat/coding-standard:"dev-master" sirbrillig/phpcs-variable-analysis:"2.x" + automattic/vipwpcs:"dev-develop" # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer diff --git a/.github/workflows/quicktest.yml b/.github/workflows/quicktest.yml index 2a437ba..24e925a 100644 --- a/.github/workflows/quicktest.yml +++ b/.github/workflows/quicktest.yml @@ -62,7 +62,7 @@ jobs: composer require --no-update --no-scripts --no-interaction squizlabs/php_codesniffer:"dev-master" phpcsstandards/phpcsutils:"dev-develop" - wp-coding-standards/wpcs:"dev-develop" + wp-coding-standards/wpcs:"dev-develop as 3.99" # Alias needed to prevent composer conflict with VIPCS. # Install dependencies and handle caching in one go. # @link https://github.com/marketplace/actions/install-php-dependencies-with-composer diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bba6ad7..b7f05df 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,7 +21,7 @@ concurrency: env: PHPCS_HIGHEST: 'dev-master' UTILS_HIGHEST: 'dev-develop' - WPCS_HIGHEST: 'dev-develop' + WPCS_HIGHEST: 'dev-develop as 3.99' # Alias needed to prevent composer conflict with VIPCS. jobs: #### TEST STAGE #### diff --git a/README.md b/README.md index 33fa713..70551e4 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ The `Yoast` standard for PHP_CodeSniffer is comprised of the following: * Select additional sniffs taken from [`PHP_CodeSniffer`](https://github.com/PHPCSStandards/PHP_CodeSniffer). * Select additional sniffs taken from [`PHPCSExtra`](https://github.com/PHPCSStandards/PHPCSExtra). * Select additional sniffs taken from [`SlevomatCodingStandard`](https://github.com/slevomat/coding-standard). +* Select additional sniffs taken from [WordPress VIP Coding Standards](https://github.com/Automattic/VIP-Coding-Standards/). * A number of custom Yoast specific sniffs. Files within version management and dependency related directories, such as the Composer `vendor` directory, are excluded from the scans by default. diff --git a/composer.json b/composer.json index 33f1946..8a9d902 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,7 @@ "require": { "php": ">=7.2", "ext-tokenizer": "*", + "automattic/vipwpcs": "^3.0.0", "php-parallel-lint/php-console-highlighter": "^1.0.0", "php-parallel-lint/php-parallel-lint": "^1.3.2", "phpcompatibility/phpcompatibility-wp": "^2.1.4", From 44c961f3a70d3d08bc7ae4adf670ddcaf508716b Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 19 Sep 2023 05:36:48 +0200 Subject: [PATCH 2/2] YoastCS rules: add a few VIP sniffs to prevent some typical WP compat bugs There is one known bug in the `WordPressVIPMinimum.Hooks.AlwaysReturnInFilter` sniff related to a redirect being done from within the filter. This has been reported upstream Automattic/VIP-Coding-Standards 719. Related to 303 Fixes 229 Impact on Yoast packages: | Plugin/Tool | Errors/Warnings | |-------------------|-----------------| | PHPUnit Polyfills | -- | WP Test Utils | -- | YoastCS | -- | WHIP | -- | Yoast Test Helper | -- | Duplicate Post | -- | Yst ACF | -- | Yst WooCommerce | -- | Yst News | -- | Yst Local | 2 (proper escaping) | Yst Video | -- | Yst Premium | 1 (false positive/reported bug) | Yst Free | 2 (1 false positive/reported bug) Note: these rules were previously already "silently" enforced via clean-up sweeps. --- Yoast/ruleset.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Yoast/ruleset.xml b/Yoast/ruleset.xml index 2a0faaf..2c938a6 100644 --- a/Yoast/ruleset.xml +++ b/Yoast/ruleset.xml @@ -405,6 +405,26 @@ + + + + + + + + + + + + + +