Commit Graph

18 Commits

Author SHA1 Message Date
Sergey Biryukov ab4800b289 Coding Standards: Update PHPCS Composer plugin to v0.6.0.
Release log: https://github.com/Dealerdirect/phpcodesniffer-composer-installer/releases/tag/v0.6.0

Props jrf.
See #49222.

git-svn-id: https://develop.svn.wordpress.org/trunk@47389 602fd350-edb4-49c9-b593-d223f7449a82
2020-02-28 01:38:58 +00:00
Jonathan Desrosiers 2dbc7e087f Build/Test Tools: Move Composer script command line directives to the PHPCS ruleset.
Also, move all arguments up to the top of the custom ruleset to make it easier to understand the conditions the ruleset is run under.

Props desrosj, jrf.
See #46152.

git-svn-id: https://develop.svn.wordpress.org/trunk@46291 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-25 14:01:51 +00:00
Jonathan Desrosiers 336960897d Build/Test Tools: Introduce automated PHP compatibility checking.
This change introduces a new Composer script, `compat` that will scan the codebase for (detectable) potential PHP compatibility issues using the `PHP_CodeSniffer` and a custom ruleset based off of the `PHPCompayibilityWP` ruleset (`phpcompat.xml.dist`).

The command will be run as a separate job within each Travis build. While many compatibility issues and false positives have already been corrected in this commit and other Trac tickets, there are still some remaining. For that reason, the job is allowed to fail while the remainder of the potential compatibility issues are investigated and addressed. After those are resolved, the job should be set as required to pass to help prevent new compatibility issues from being introduced.

Props desrosj, jrf, all PHPCompatibilityWP and PHPCompatibility contributors.
Fixes #46152.

git-svn-id: https://develop.svn.wordpress.org/trunk@46290 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-25 13:46:55 +00:00
Jonathan Desrosiers e269403184 Build/Test Tools: Specify PHP 5.6 as the required version of PHP in Composer.
Props ayeshrajans, jrf, netweb.
Fixes #48081.

git-svn-id: https://develop.svn.wordpress.org/trunk@46200 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-20 17:32:23 +00:00
Jonathan Desrosiers 7e69921a5a Build/Test Tools: Improvements to Composer scripts.
Prefixing a script command with `@php ` ensures that the script runs with the same version of PHP that Composer is installed with (and not the system default).

This change also updates the `phpcs` and `phpcbf` commands to use the version of PHPCS installed by Composer.

The `—standard` is no longer explicitly passed to the command. By default, PHPCS will look for `phpcs.xml.dist`, which is the name of the custom standards file currently in Core.

Props dingo_d, jrf.
Fixes #47853.

git-svn-id: https://develop.svn.wordpress.org/trunk@46187 602fd350-edb4-49c9-b593-d223f7449a82
2019-09-19 15:00:14 +00:00
Gary Pendergast 3d1714de71 Coding Standards: Move the remaining PHPCS errors to report as warnings, and add Travis tests.
The remaining error-level coding standards issues (specifically, associated with the sniffs `WordPress.PHP.YodaConditions.NotYoda`, `WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase`, `WordPress.DB.PreparedSQL.InterpolatedNotPrepared`, `WordPress.DB.PreparedSQL.NotPrepared`, and `WordPress.Files.FileName.InvalidClassFileName`) are marked as warnings, until they're all addressed.

This change allows us to run linting on Travis across the entire codebase, ensuring no other error-level violations can be introduced.

Additionally, PHPCS will now cache results locally, drastically improving performance for subsequent checks: scanning the entire codebase takes 1-2 minutes the first time, and less than one second for subsequent checks.

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45665 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-19 07:47:16 +00:00
Gary Pendergast e6b7205a8f Coding Standards: Upgrade WPCS to 2.1.1.
Noteable changes:
- WPCS now throws warnings when non-strict comparisons are used. There are quite a few of them in Core. 🙃
- WPCS now detects and warns for assignments in loop conditions.

See #47632.



git-svn-id: https://develop.svn.wordpress.org/trunk@45600 602fd350-edb4-49c9-b593-d223f7449a82
2019-07-05 02:49:53 +00:00
Gary Pendergast 2ec6c8f3d3 Build Tools: Upgrade WPCS to 2.0.0.
A few sniffs have been renamed, this change includes the relevant `phpcs:ignore` comment updates.

Fixes #46002.



git-svn-id: https://develop.svn.wordpress.org/trunk@44645 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-18 02:14:24 +00:00
Gary Pendergast 992184cf73 Coding Standards: Upgrade WPCS to 1.2.1.
This upgrade fixes quite a few false positives, as well as auto-fixing some indenting issues.

Fixes #45956.



git-svn-id: https://develop.svn.wordpress.org/trunk@44574 602fd350-edb4-49c9-b593-d223f7449a82
2019-01-12 06:40:16 +00:00
Gary Pendergast a75d153eee Coding Standards: Upgrade WPCS to 1.0.0
WPCS 1.0.0 includes a bunch of new auto-fixers, which drops the number of coding standards issues across WordPress significantly. Prior to running the auto-fixers, there were 15,312 issues detected. With this commit, we now drop to 4,769 issues.

This change includes three notable additions:
- Multiline function calls must now put each parameter on a new line.
- Auto-formatting files is now part of the `grunt precommit` script. 
- Auto-fixable coding standards issues will now cause Travis failures.

Fixes #44600.



git-svn-id: https://develop.svn.wordpress.org/trunk@43571 602fd350-edb4-49c9-b593-d223f7449a82
2018-08-17 01:50:26 +00:00
jrf 3581d34bb0 Build/Tools: Update PHPCS ruleset for WP Core and related Composer setup.
`.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
2018-06-15 15:56:58 +00:00
Gary Pendergast dc24919339 Build Tools: Update the description in package.json and composer.json.
The description now matches the tagline on the front page of WordPress.org.

Props ocean90.
Fixes #43558.



git-svn-id: https://develop.svn.wordpress.org/trunk@42961 602fd350-edb4-49c9-b593-d223f7449a82
2018-04-05 07:15:25 +00:00
Gary Pendergast aee223f097 Build Tools: Add a composer.json for development environments.
This allows Core developers to more easily run coding standards checks on PHP code.

Props netweb.
Fixes #43558.



git-svn-id: https://develop.svn.wordpress.org/trunk@42960 602fd350-edb4-49c9-b593-d223f7449a82
2018-04-05 07:04:08 +00:00
Scott Taylor 7b0cd0ac85 Bootstrap: move `composer.{json|lock}` into `src`.
See #36335.


git-svn-id: https://develop.svn.wordpress.org/trunk@38409 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 19:05:28 +00:00
Scott Taylor 5d4485b184 Bootstrap: exclude more files from the `autoloader.classmap` in `composer.json`.
See #36335.


git-svn-id: https://develop.svn.wordpress.org/trunk@38395 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 05:39:31 +00:00
Scott Taylor 1c52ad1196 Bootstrap: run `composer require xrstf/composer-php52` to get the updated suggested version. Change the `vendor-dir` to `wp-vendor`.
See #36335.


git-svn-id: https://develop.svn.wordpress.org/trunk@38393 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-27 03:35:35 +00:00
Scott Taylor 07fe41b23d Bootstrap: exclude some files from the Composer autoload setup via `exclude-from-classmap`.
See #36335.



git-svn-id: https://develop.svn.wordpress.org/trunk@38391 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 22:21:00 +00:00
Scott Taylor 39a145e0e1 Bootstrap: add a `composer.json` file to the project. No code relies on it (yet), and no `vendor` dir is checked in (yet). No autoloader is being used (yet). Taking this first step will hopefully encourage the perfectionists of our world to scrutinize each line.
To fiddle around with what it does, run `composer install` from the project root. If you do not have Composer installed:
https://getcomposer.org/doc/00-intro.md#locally

tl;dr for Mac/Homebrew users: `brew install composer`

Classes from `wp-includes` and `wp-admin` are eligible for autoloading via `autoload.classmap`. Through a tornado of recent commits, many unsuitable files have been transitioned into a more acceptable state for autoloading: 1 file per class, no side effects.

The file bootstrap in `wp-settings.php` can transition into `autoload.files`. This will be done with care and attention.

See #36335.


git-svn-id: https://develop.svn.wordpress.org/trunk@38384 602fd350-edb4-49c9-b593-d223f7449a82
2016-08-26 20:59:54 +00:00