diff options
author | Sergey Biryukov <sergeybiryukov@git.wordpress.org> | 2023-09-26 00:24:43 +0000 |
---|---|---|
committer | Sergey Biryukov <sergeybiryukov@git.wordpress.org> | 2023-09-26 00:24:43 +0000 |
commit | ff96003a0f91394d8e0f37643a5c96aaad42299b (patch) | |
tree | f3fe5f5fb21e19271f364f4f286be9c0dffa2861 /phpcs.xml.dist | |
parent | b011e827cf8af31cc38b28c9a5d9f90ad8fbfab2 (diff) | |
download | wordpress-ff96003a0f91394d8e0f37643a5c96aaad42299b.tar.gz wordpress-ff96003a0f91394d8e0f37643a5c96aaad42299b.zip |
Coding Standards: Upgrade WPCS to version 3.0.0.
This is an important release which makes significant changes to improve the accuracy, performance, stability and maintainability of all sniffs, as well as making WordPressCS much better at handling modern PHP.
WordPressCS 3.0.0 contains breaking changes, both for people using ignore annotations, people maintaining custom rulesets, as well as for sniff developers who maintain a custom PHPCS standard based on WordPressCS.
If you are an end-user or maintain a custom WordPressCS based ruleset, please start by reading the [https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-3.0.0-for-ruleset-maintainers Upgrade Guide to WordPressCS 3.0.0 for ruleset maintainers] which lists the most important changes and contains a step by step guide for upgrading.
If you are a maintainer of an external standard based on WordPressCS and any of your custom sniffs are based on or extend WordPressCS sniffs, please read the [https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-3.0.0-for-Developers-of-external-standards Upgrade Guide to WordPressCS 3.0.0 for Developers].
In all cases, please read the complete changelog carefully before you upgrade.
This commit:
* Updates the Composer dependencies to use the new version, including updating the underlying PHP_CodeSniffer dependency to the new minimum supported version for WPCS.[[BR]] Note: the Composer PHPCS installer plugin is no longer explicitly required as it is now a dependency of WPCS, so the dependency is inherited automatically.
* Updates the ruleset for WPCS 3.0.0. This includes:
* Raising the memory limit to be on the safe side as WPCS 3.0.0 contains a lot more sniffs.
* Removing explicit inclusions of extra rules, which have now been added to the `WordPress-Core` ruleset..
* Updating property names for select sniffs.
* Updating one exclusion — the `WordPress.CodeAnalysis.AssignmentInCondition` sniff has been (partially) replaced by the `Generic.CodeAnalysis.AssignmentInCondition` sniff.
* Adding one new exclusion.
* Downgrades one new error to a warning.[[BR]] The `Generic.Files.OneObjectStructurePerFile` sniff enforces that there is only one OO structure declaration per file. At this time, this sniff would yield 29 errors. By downgrading the sniff to a ''warning'', the build can pass and the issues can be fixed in due time. For now, the test directory will be excluded until the issues are fixed (as the test directory CS run does not allow for warnings).
* Updates ignore annotations for WPCS 3.0.0.
Reference: [https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/3.0.0 WPCS 3.0.0 release notes].
Follow-up to [43571], [44574], [45600], [47927].
Props jrf, jorbin, desrosj.
See #59161.
git-svn-id: https://develop.svn.wordpress.org/trunk@56695 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'phpcs.xml.dist')
-rw-r--r-- | phpcs.xml.dist | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/phpcs.xml.dist b/phpcs.xml.dist index a617d8b669..00ac927d07 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -15,11 +15,11 @@ <!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. --> <arg name="cache" value=".cache/phpcs.json"/> - <!-- Set the memory limit to 256M. + <!-- Set the memory limit to 512M. For most standard PHP configurations, this means the memory limit will temporarily be raised. Ref: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#specifying-phpini-settings --> - <ini name="memory_limit" value="256M"/> + <ini name="memory_limit" value="512M"/> <!-- Strip the filepaths down to the relevant bit. --> <arg name="basepath" value="./"/> @@ -113,22 +113,6 @@ --> <rule ref="WordPress-Core"/> - <rule ref="WordPress.CodeAnalysis.EmptyStatement"/> - - <!-- Enforce no parenthesis for language constructs, and only one space immediately after. - Including this rule is temporary until it is moved from the WordPress-Extra ruleset to - the WordPress-Core ruleset upstream. - --> - <rule ref="PEAR.Files.IncludingFile.BracketsNotRequired"> - <type>warning</type> - </rule> - <rule ref="PEAR.Files.IncludingFile.UseRequire"> - <type>warning</type> - </rule> - <rule ref="PEAR.Files.IncludingFile.UseRequireOnce"> - <type>warning</type> - </rule> - <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/> <!-- @@ -138,6 +122,11 @@ --> <!-- These rules are being set as warnings instead of errors, so we can error check the entire codebase. --> + <rule ref="Generic.Files.OneObjectStructurePerFile.MultipleFound"> + <type>warning</type> + <!-- Exclude the unit tests as no warnings are allowed there. Note: these issues should be fixed and the exclude removed! --> + <exclude-pattern>/tests/phpunit/*</exclude-pattern> + </rule> <rule ref="WordPress.DB.PreparedSQL.InterpolatedNotPrepared"> <type>warning</type> </rule> @@ -153,7 +142,7 @@ <rule ref="WordPress.NamingConventions.ValidVariableName"> <properties> - <property name="customPropertiesWhitelist" type="array"> + <property name="allowed_custom_properties" type="array"> <!-- From database structure queries. --> <element value="Collation"/> <element value="Column_name"/> @@ -209,7 +198,7 @@ <rule ref="WordPress.PHP.NoSilencedErrors"> <properties> - <property name="custom_whitelist" type="array"> + <property name="customAllowedFunctionsList" type="array"> <element value="ssh2_connect"/> <element value="ssh2_auth_password"/> <element value="ssh2_auth_pubkey_file"/> @@ -239,6 +228,11 @@ ############################################################################# --> + <!-- Assignments in while conditions are a valid method of looping over iterables. --> + <rule ref="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"> + <exclude-pattern>*</exclude-pattern> + </rule> + <!-- Exclude checking of line endings when reporting errors, but fix them when running phpcbf. Git and SVN manage these pretty well cross-platform as "native". Allow configuration files. --> @@ -255,6 +249,12 @@ <exclude-pattern>/wp-tests-config-sample\.php</exclude-pattern> </rule> + <!-- Exclude sample config from modernization to prevent breaking CI workflows based on WP-CLI scaffold. + See: https://core.trac.wordpress.org/ticket/48082#comment:16 --> + <rule ref="Modernize.FunctionCalls.Dirname.FileConstant"> + <exclude-pattern>/wp-tests-config-sample\.php</exclude-pattern> + </rule> + <rule ref="PEAR.NamingConventions.ValidClassName.Invalid"> <exclude-pattern>/tests/phpunit/tests/*</exclude-pattern> <!-- Exclude some old classes that cannot be renamed, as it would break back compat. --> @@ -274,9 +274,10 @@ <exclude-pattern>/src/wp-includes/class-wpdb\.php</exclude-pattern> </rule> - <!-- Assignments in while conditions are a valid method of looping over iterables. --> - <rule ref="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"> - <exclude-pattern>*</exclude-pattern> + <!-- Temporarily ignore this sniff for block files until the changes from upstream make it into core. + This can be removed once the block-library package is updated for WP 6.4. --> + <rule ref="Squiz.Functions.MultiLineFunctionDeclaration.SpaceAfterFunction"> + <exclude-pattern>/src/wp-includes/blocks/*</exclude-pattern> </rule> <!-- Allow the WP DB Class and related tests for usage of direct database access functions. --> |