Skip to content

Commit

Permalink
Build/Tools: Update PHPCS ruleset for WP Core and related Composer se…
Browse files Browse the repository at this point in the history
…tup.

`.gitignore` + `svn:ignore`:
* Add the typical filenames of overloaded PHPCS configs to `.gitignore`.

Composer:
* Use the `develop` (Packagist `dev-master`) version of WPCS as it contains lots of bugfixes.
* Remove the PHPCS dependency. This is a dependency of WPCS, not of WP Core itself. This will also make sure that the PHPCS version used is always one which is supported by WPCS.
* Refreshed the `composer.lock` file.

PHPCS ruleset:
* Removed a reference to a sniff which doesn't exist in WPCS yet.
* Use the PHPCS 3.x `basepath` option to clean up the file paths PHPCS shows in the reports.
* Use the PHPCS 3.x `parallel` option to enable parallel scanning whenever possible to speed up the scans.
* Whitelist the `wp-includes/l10n.php` file from issues being reported by the `WordPress.WP.I18n` sniff.

Fixes #44366.

git-svn-id: https://develop.svn.wordpress.org/trunk@43348 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
jrfnl committed Jun 15, 2018
1 parent 78f2b0e commit 3581d34
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -7,6 +7,8 @@ wp-tests-config.php

# Files and folders related to build/test tools
/phpunit.xml
/.phpcs.xml
/phpcs.xml
/tests/phpunit/data/plugins/wordpress-importer
/tests/phpunit/data/.trac-ticket-cache*
/tests/qunit/compiled.html
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Expand Up @@ -11,8 +11,7 @@
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
"squizlabs/php_codesniffer": "^3.2.3",
"wp-coding-standards/wpcs": "dev-feature/new-multi-line-comment-formatting-sniffs"
"wp-coding-standards/wpcs": "dev-master"
},
"scripts": {
"format": "phpcbf --standard=phpcs.xml.dist --report-summary --report-source",
Expand Down
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion phpcs.xml.dist
Expand Up @@ -4,10 +4,15 @@

<rule ref="WordPress-Core"/>
<rule ref="WordPress.CodeAnalysis.EmptyStatement"/>
<rule ref="WordPress.Commenting.DocblockFormat"/>

<arg name="extensions" value="php"/>

<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>

<!-- Check up to 20 files simultanously. -->
<arg name="parallel" value="20"/>

<!-- Show sniff codes in all reports -->
<arg value="ps"/>

Expand Down Expand Up @@ -69,6 +74,12 @@
<exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
</rule>

<!-- Whitelist the I18n functions file from 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>
</rule>

<rule ref="Generic.Functions.FunctionCallArgumentSpacing">
<exclude-pattern>/wp-config\.php</exclude-pattern>
<exclude-pattern>/wp-config-sample\.php</exclude-pattern>
Expand Down

0 comments on commit 3581d34

Please sign in to comment.