Skip to content

Commit

Permalink
Merge pull request #365 from Yoast/JRF/yoastcs-wp-related-rules
Browse files Browse the repository at this point in the history
YoastCS: add extra WP related rules
  • Loading branch information
jrfnl authored Dec 14, 2023
2 parents f209bca + 44c961f commit 1f0f6a7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/basics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/quicktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ####
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 20 additions & 0 deletions Yoast/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,26 @@
</rule>


<!--
#############################################################################
SNIFFS TO PREVENT SOME WP COMPATIBILITY ISSUES
Some of these sniffs are expected to end up in WordPressCS in the future.
#############################################################################
-->
<!-- Verify method signatures for compatibility with a few typical WP parent classes. -->
<rule ref="WordPressVIPMinimum.Classes.DeclarationCompatibility"/>

<!-- Verify that all functions which are hooked into a filter always return a value. -->
<rule ref="WordPressVIPMinimum.Hooks.AlwaysReturnInFilter"/>

<!-- Verify that some typical functions with mixed return types are not nested.
This can prevent some TypeErrors and related deprecation notices. -->
<rule ref="WordPressVIPMinimum.Security.EscapingVoidReturnFunctions"/>

<!-- Verify that the correct escaping function is used based on the context. -->
<rule ref="WordPressVIPMinimum.Security.ProperEscapingFunction"/>


<!--
#############################################################################
SNIFFS TO ENFORCE CODE MODERNIZATION
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 1f0f6a7

Please sign in to comment.