Skip to content

Commit

Permalink
PHPCS: Refresh PHPCS config
Browse files Browse the repository at this point in the history
 - Add comments and links for those not familiar with PHPCS configuration file.
 - Add a default starting point for scanning. Can be overridden in the command line.
 - Exclude `vendor/` directory, since this is third-party code.
 - Add options to show violation code and progress.
 - Add basepath option so reports don't include full absolute path to file.
 - Add parallel processing for quicker reporting of PHPCS.
 - Limit scans to PHP files (copied from preference in Makefile). PHPCS 4 will remove the JS tokenizer anyway.
 - Add PHPCompatibilityWP ruleset, with a testVersion of 7.3 and above.
 - Change from deprecated / removed `WordPress-VIP` ruleset in WordPress Coding Standards, to `WordPress-VIP-Go` ruleset from VIP Coding Standards.

See #1032.
  • Loading branch information
GaryJones committed Dec 14, 2019
1 parent a9c30df commit bcbbbd4
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<?xml version="1.0"?>
<ruleset name="VIP-Go-mu-plugins">
<description>VIP Go mu-plugins</description>
<description>Custom ruleset for VIP Go mu-plugins</description>

<config name="ignore_warnings_on_exit">true</config>
<!-- For help in understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- For help in using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->

<!-- What to scan -->
<file>.</file>

<!-- Ignoring Files and Folders:
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->

<!-- Submodules - these should have their own PHPCS configurations -->
<exclude-pattern>advanced-post-cache/*</exclude-pattern>
Expand All @@ -25,12 +32,32 @@
<exclude-pattern>drop-ins/*</exclude-pattern>
<exclude-pattern>shared-plugins/*</exclude-pattern>
<exclude-pattern>vaultpress/*</exclude-pattern>
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>wordpress-importer/*</exclude-pattern>
<exclude-pattern>wp-cron-control/*</exclude-pattern>

<!-- Other files (borrowed and modified from a Symfony package) -->
<exclude-pattern>lib/proxy/ip-utils.php</exclude-pattern>
<exclude-pattern>tests/test-lib-proxy-ip-utils.php</exclude-pattern>

<rule ref="WordPress-VIP"/>
<!-- How to scan -->
<!-- Show sniff and progress -->
<arg value="sp"/>
<!-- Strip the file paths down to the relevant bit -->
<arg name="basepath" value="."/>
<!-- Enables parallel processing when available for faster results. -->
<arg name="parallel" value="8"/>
<!-- Limit to PHP files -->
<arg name="extensions" value="php"/>

<config name="ignore_warnings_on_exit">true</config>

<!-- Rules: Check PHP version compatibility - see
https://github.com/PHPCompatibility/PHPCompatibilityWP -->
<rule ref="PHPCompatibilityWP"/>
<!-- For help in understanding this testVersion:
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
<config name="testVersion" value="7.3-"/>

<rule ref="WordPress-VIP-Go"/>
</ruleset>

0 comments on commit bcbbbd4

Please sign in to comment.