wordpress/phpcs.xml.dist

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

357 lines
15 KiB
Plaintext
Raw Permalink Normal View History

<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
<description>Apply WordPress Coding Standards to all Core files</description>
<!--
#############################################################################
COMMAND LINE ARGUMENTS
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset
#############################################################################
-->
<!-- Only scan PHP files. -->
<arg name="extensions" value="php"/>
<!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
<arg name="cache" value=".cache/phpcs.json"/>
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
2023-09-26 00:24:43 +00:00
<!-- 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
-->
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
2023-09-26 00:24:43 +00:00
<ini name="memory_limit" value="512M"/>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>
<!-- Check up to 20 files simultaneously. -->
<arg name="parallel" value="20"/>
<!-- Show sniff codes in all reports. -->
<arg value="ps"/>
<!--
#############################################################################
FILE SELECTION
Set which files will be subject to the scans executed using this ruleset.
#############################################################################
-->
<file>.</file>
<!-- Exclude the build folder in the current directory. -->
<exclude-pattern type="relative">^build/*</exclude-pattern>
<!-- Directories and third party library exclusions. -->
<exclude-pattern>/node_modules/*</exclude-pattern>
<exclude-pattern>/vendor/*</exclude-pattern>
<exclude-pattern>/src/wp-admin/includes/class-ftp*</exclude-pattern>
<exclude-pattern>/src/wp-admin/includes/class-pclzip\.php</exclude-pattern>
<exclude-pattern>/src/wp-admin/includes/deprecated\.php</exclude-pattern>
<exclude-pattern>/src/wp-admin/includes/ms-deprecated\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/atomlib\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-avif-info\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-IXR\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-json\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-phpass\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-pop3\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-requests\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-simplepie\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-snoopy\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/deprecated\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/ms-deprecated\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/pluggable-deprecated\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/rss\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/assets/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/blocks/*/*.asset.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/blocks/blocks-json.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/ID3/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/IXR/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/js/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/PHPMailer/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/Requests/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/SimplePie/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/sodium_compat/*</exclude-pattern>
<exclude-pattern>/src/wp-includes/Text/*</exclude-pattern>
<!-- Test data and fixtures. -->
<exclude-pattern>/tests/phpunit/build*</exclude-pattern>
<exclude-pattern>/tests/phpunit/data/*</exclude-pattern>
<exclude-pattern>/tools/*</exclude-pattern>
<!-- Drop-in plugins. -->
<exclude-pattern>/src/wp-content/advanced-cache\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/blog-deleted\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/blog-inactive\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/blog-suspended\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/db-error\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/db\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/fatal-error-handler\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/install\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/maintenance\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/object-cache\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/php-error\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/sunrise\.php</exclude-pattern>
<!-- Must-Use plugins. -->
<exclude-pattern>/src/wp-content/mu-plugins/*</exclude-pattern>
<!-- Plugins. -->
<exclude-pattern>/src/wp-content/plugins/*</exclude-pattern>
<!-- Themes except the twenty* themes. -->
<exclude-pattern>/src/wp-content/themes/(?!twenty)*</exclude-pattern>
<!-- Translation files. -->
<exclude-pattern>/src/wp-content/languages/*</exclude-pattern>
<!--
#############################################################################
SET UP THE RULESET
#############################################################################
-->
<rule ref="WordPress-Core"/>
<!--
#############################################################################
SNIFF-SPECIFIC CONFIGURATION
#############################################################################
-->
<!-- These rules are being set as warnings instead of errors, so we can error check the entire codebase. -->
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
2023-09-26 00:24:43 +00:00
<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>
<rule ref="WordPress.DB.PreparedSQL.NotPrepared">
<type>warning</type>
</rule>
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<type>warning</type>
</rule>
<rule ref="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase">
<type>warning</type>
</rule>
<rule ref="WordPress.NamingConventions.ValidVariableName">
<properties>
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
2023-09-26 00:24:43 +00:00
<property name="allowed_custom_properties" type="array">
<!-- From database structure queries. -->
<element value="Collation"/>
<element value="Column_name"/>
<element value="Default"/>
<element value="Extra"/>
<element value="Field"/>
<element value="Index_type"/>
<element value="Key"/>
<element value="Key_name"/>
<element value="Msg_text"/>
<element value="Non_unique"/>
<element value="Null"/>
<element value="Sub_part"/>
<element value="Type"/>
<!-- From plugin/theme data. -->
<element value="authorAndUri"/>
<element value="Name"/>
<element value="Version"/>
<!-- From the result of wp_xmlrpc_server::wp_getPageList(). -->
<element value="dateCreated"/>
<!-- From DOMDocument. -->
<element value="childNodes"/>
<element value="firstChild"/>
<element value="formatOutput"/>
<element value="lastChild"/>
<element value="nodeName"/>
<element value="nodeType"/>
<element value="nodeValue"/>
<element value="parentNode"/>
<element value="preserveWhiteSpace"/>
<element value="textContent"/>
<!-- From PHPMailer. -->
<element value="AltBody"/>
<element value="Body"/>
<element value="CharSet"/>
<element value="ContentType"/>
<element value="Encoding"/>
<element value="Hostname"/>
<element value="mailHeader"/>
<element value="MIMEBody"/>
<element value="MIMEHeader"/>
<element value="Sender"/>
<element value="Subject"/>
<!-- From PHPUnit_Util_Getopt. -->
<element value="longOptions"/>
<!-- From POP3. -->
<element value="ERROR"/>
<!-- From ZipArchive. -->
<element value="numFiles"/>
</property>
</properties>
</rule>
<rule ref="WordPress.PHP.NoSilencedErrors">
<properties>
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
2023-09-26 00:24:43 +00:00
<property name="customAllowedFunctionsList" type="array">
<element value="ssh2_connect"/>
<element value="ssh2_auth_password"/>
<element value="ssh2_auth_pubkey_file"/>
<element value="ftp_ssl_connect"/>
<element value="ftp_connect"/>
<element value="ftp_get_option"/>
<element value="ftp_set_option"/>
<element value="disk_free_space"/>
<element value="getimagesize"/>
<element value="iptcparse"/>
<element value="exif_read_data"/>
<element value="gzinflate"/>
<element value="gzuncompress"/>
<element value="gzdecode"/>
<element value="imagecreatefromwebp"/>
<element value="imagecreatefromavif"/>
</property>
</properties>
</rule>
<!--
#############################################################################
SELECTIVE EXCLUSIONS
Exclude specific files for specific sniffs and/or exclude sub-groups in sniffs.
These exclusions are listed ordered by alphabetic sniff name.
#############################################################################
-->
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
2023-09-26 00:24:43 +00:00
<!-- 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. -->
<rule ref="Generic.Files.LineEndings">
<exclude-pattern>/wp-config\.php</exclude-pattern>
<exclude-pattern>/wp-config-sample\.php</exclude-pattern>
<exclude phpcs-only="true" name="Generic.Files.LineEndings"/>
</rule>
<rule ref="Generic.Functions.FunctionCallArgumentSpacing">
<exclude-pattern>/wp-config\.php</exclude-pattern>
<exclude-pattern>/wp-config-sample\.php</exclude-pattern>
<exclude-pattern>/wp-tests-config\.php</exclude-pattern>
<exclude-pattern>/wp-tests-config-sample\.php</exclude-pattern>
</rule>
<!-- Exclude forbidding goto in the HTML Processor, which mimics algorithms that are written
this way in the HTML specification, and these particular algorithms are complex and
highly imperative. Avoiding the goto introduces a number of risks that could make it
more difficult to maintain the relationship to the standard, lead to subtle differences
in the parsing, and distance the code from its standard. -->
<rule ref="Generic.PHP.DiscourageGoto.Found">
<exclude-pattern>/wp-includes/html-api/class-wp-html-processor\.php</exclude-pattern>
<exclude-pattern>/wp-includes/html-api/class-wp-html-doctype-info\.php</exclude-pattern>
</rule>
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
2023-09-26 00:24:43 +00:00
<!-- 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. -->
<exclude-pattern>/src/wp-admin/includes/class-wp-filesystem-ftpsockets\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-oembed\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-oembed-controller\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-xmlrpc-server\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-text-diff-renderer-inline\.php</exclude-pattern>
</rule>
<!-- Exclude some old classes that cannot be renamed, as it would break back compat. -->
<rule ref="PEAR.NamingConventions.ValidClassName.StartWithCapital">
<exclude-pattern>/src/wp-admin/includes/class-wp-list-table-compat\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-dependency\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-editor\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-xmlrpc-server\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wpdb\.php</exclude-pattern>
</rule>
<!-- Allow the WP DB Class and related tests for usage of direct database access functions. -->
<rule ref="WordPress.DB.RestrictedFunctions">
<exclude-pattern>/src/wp-includes/class-wpdb\.php</exclude-pattern>
<exclude-pattern>/tests/phpunit/tests/db/charset\.php</exclude-pattern>
</rule>
<!-- Allow the WP DB related tests for issues with prepared SQL placeholders
(as the handling of those are being tested). -->
<rule ref="WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare">
<exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
</rule>
<rule ref="WordPress.DB.PreparedSQLPlaceholders.UnsupportedPlaceholder">
<exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
</rule>
<rule ref="WordPress.DB.PreparedSQLPlaceholders.UnescapedLiteral">
<exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
</rule>
<rule ref="WordPress.DB.PreparedSQL.NotPrepared">
<exclude-pattern>/tests/phpunit/tests/admin/includesSchema\.php</exclude-pattern>
<exclude-pattern>/tests/phpunit/tests/multisite/site\.php</exclude-pattern>
</rule>
<!-- Exclude the unit tests from the file name rules. -->
<rule ref="WordPress.Files.FileName">
<exclude-pattern>/tests/phpunit/*</exclude-pattern>
</rule>
<!-- WPCS1620: template.php isn't a template tag file. -->
<rule ref="WordPress.Files.FileName.InvalidTemplateTagFileName">
<exclude-pattern>/src/wp-includes/template\.php</exclude-pattern>
</rule>
<!-- Exclude some incorrectly named files that won't be renamed. -->
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>/src/wp-admin/includes/class-wp-list-table-compat\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-dependency\.php</exclude-pattern>
<exclude-pattern>/src/wp-includes/class-wp-editor\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/themes/twentyeleven/inc/widgets\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/themes/twentyfourteen/inc/widgets\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/themes/twentyfourteen/inc/featured-content\.php</exclude-pattern>
</rule>
<!-- WPCS1621: These files are expected to use _ instead of -. -->
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>/src/_index\.php</exclude-pattern>
<exclude-pattern>/src/wp-admin/_index\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/themes/twentythirteen/taxonomy-post_format\.php</exclude-pattern>
<exclude-pattern>/src/wp-content/themes/twentyfourteen/taxonomy-post_format\.php</exclude-pattern>
</rule>
<!-- Allow the I18n functions file for issues identified by the I18n sniff
(such as calling the low-level translate() function). -->
<rule ref="WordPress.WP.I18n">
<exclude-pattern>/src/wp-includes/l10n\.php</exclude-pattern>
<exclude-pattern>/tests/phpunit/tests/l10n\.php</exclude-pattern>
<exclude-pattern>/tests/phpunit/tests/l10n/loadTextdomainJustInTime\.php</exclude-pattern>
</rule>
<!-- Translator comments aren't needed in unit tests. -->
<rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
<exclude-pattern>/tests/*</exclude-pattern>
</rule>
</ruleset>