Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YoastCS: add extra WP related rules #365

Merged
merged 2 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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