Commit graph

2795 commits

Author SHA1 Message Date
Juliette
5b3cde7f0c
Add Code of Conduct
Based on the [Contributor Covenant](https://www.contributor-covenant.org) version 2.0.

As there is no email address available for the project, I'm proposing to use the WP Core Slack channel #core-coding-standards as the official channel to report violations. Depending on the violation, details can shared in private via DMs if needed to protect the privacy of the parties involved.
2022-05-16 14:16:40 +02:00
Denis Žoljom
1702977235
Merge pull request #2049 from WordPress/feature/up-minimum-phpcs-version-3.6.2
Composer: up the minimum PHPCS version to 3.6.2
2022-05-16 13:32:45 +02:00
jrfnl
e5e0fdf7e2
Composer: up the minimum PHPCS version to 3.6.2
While the minimum PHPCS version has already been upped to PHPCS 3.5.0 previously for the WPCS 3.0.0 branch, I'm proposing to up it yet further to the latest PHPCS version available.

PHP 8.0 and 8.1 introduced a lot of new syntaxes and, while a lot of this can be supported for older PHPCS versions via PHPCSUtils, this will always impact performance and precision, so it is strongly advisable to use the latest PHPCS version as the new minimum if we want to support the newly available PHP syntaxes.

For now, I'm upping the minimum version to PHPCS 3.6.2, which is the latest PHPCS release. This will unblock PRs to add support for PHP 8.0 features to WPCS.
Once PHPCS 3.7.0 has been released, the minimum PHPCS version should be upped again to unblock adding support for PHP 8.1 features to WPCS.

Includes updating the GH Actions matrixes for this change.

Also see #2048
2022-05-16 13:25:05 +02:00
Denis Žoljom
7415105b8d
Merge pull request #2046 from WordPress/feature/composer-lint-script-show-deprecated
GH Actions: show deprecations when linting
2022-04-26 09:13:06 +02:00
Denis Žoljom
445ff65acc
Merge pull request #2045 from WordPress/feature/core-add-gitmergeconflict-sniff
Core: add the `Generic.VersionControl.GitMergeConflict` sniff
2022-04-26 09:12:50 +02:00
Denis Žoljom
24635adb92
Merge pull request #2047 from WordPress/feature/composer-update-lint-dependencies
Composer: update PHP Parallel Lint and Console Highlighter
2022-04-24 09:02:23 +02:00
jrfnl
b7e4c7a2d2
Composer: update PHP Parallel Lint and Console Highlighter
PHP Console Highlighter has released version `1.0.0` and PHP Parallel Lint version `1.3.2` is the first PHP Parallel Lint version which supports PHP Console Highlighter `1.0.0`.

As the minimum supported PHP version is still PHP 5.3 for both, we can safely update both dependency requirements.

Refs:
* https://github.com/php-parallel-lint/PHP-Console-Highlighter/releases/tag/v1.0.0
* https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases/tag/v1.3.2
2022-04-24 03:19:04 +02:00
jrfnl
fc6958b0c9
GH Actions: show deprecations when linting
While rare, there are some deprecations which PHP can show when a file is being linted.
By default these are ignored by PHP-Parallel-Lint.

Apparently though, there is an option to show them (wasn't documented until recently), so let's turn that option on.
2022-04-22 16:08:59 +02:00
jrfnl
664adf643a
Core: add the Generic.VersionControl.GitMergeConflict sniff
Fixes 1500
2022-04-22 15:42:12 +02:00
Gary Jones
16ed111ed4
Merge pull request #2034 from WordPress/feature/ghactions-fix-xmllint 2022-03-19 20:20:18 +00:00
jrfnl
abc2d8540d
GH Actions/CS: fix build failure
Fix failing installation of the xmllint tooling.
2022-03-19 09:46:38 +01:00
Gary Jones
a93d2970a3
Merge pull request #2030 from jrfnl/feature/ghactions-update-various-actions 2022-03-09 12:02:18 +00:00
jrfnl
186f90eca4
GH Actions: version update for various predefined actions
A number of predefined actions have had major release, which warrant an update the workflow(s).

These updates don't actually contain any changed functionality, they are mostly just a change of the Node version used by the action itself (from Node 14 to Node 16).

Refs:
* https://github.com/actions/checkout/releases
2022-03-05 18:51:19 +01:00
Denis Žoljom
7b39722c38
Merge pull request #2026 from WordPress/feature/2025-croninterval-bugfix-parentheses
WP/CronInterval: bug fix for parentheses
2022-02-07 10:38:48 +01:00
jrfnl
dd26f30297 WP/CronInterval: bug fix for parentheses
This allows for a time calculation to be wrapped in parentheses.

Fixes 2025

---

Note: just looking at the code, I can see multiple additional improvements which could/should be made:
* Only search for close parenthesis as a "valueEnd" if the `$valueStart` token is an open parenthesis.
* Allow for more assignment operators - the new schedule could be build up bit by bit and only assigned to the array later.

These additional things are not addressed here. This just addresses the immediate issue.
2022-02-04 12:33:05 +01:00
Denis Žoljom
73f3d69b3a
Merge pull request #2023 from slaFFik/patch-1
README.md: Update the minimum supported PHP version
2021-12-30 20:26:09 +01:00
Slava Abakumov
0052562dee
Update the min support PHP version 2021-12-30 16:39:36 +02:00
Gary Jones
d54ee0a393
Merge pull request #2022 from jrfnl/feature/ci-various-updates 2021-12-24 13:30:51 +00:00
jrfnl
17380017de GH Actions: version update for ramsey/composer-install
The action used to install Composer packages and handle the caching has released a new major (and some follow-up patch releases), which means, the action reference needs to be updated to benefit from it.

Includes adding `--no-interaction` to "plain" Composer commands to potentially prevent CI hanging if, for whatever reason, interaction would be needed in the future.

Refs:
* https://github.com/ramsey/composer-install/releases/tag/2.0.0
* https://github.com/ramsey/composer-install/releases/tag/2.0.1
* https://github.com/ramsey/composer-install/releases/tag/2.0.2
2021-12-24 05:45:02 +01:00
jrfnl
3d68298834 GH Actions: update for the release of PHP 8.1
This commit makes the necessary adjustments to the test matrix to account for that.

Note: the protected branch settings should be adjusted after this change to include the two new PHP 8.1 builds.
2021-12-23 05:09:03 +01:00
jrfnl
814d1015b6 GH Actions: use error_reporting=-1
... as `E_ALL` does not always contain _all_ errors across PHP versions.
2021-12-23 05:07:10 +01:00
jrfnl
94a7102d3e GH Actions: auto-cancel previous builds for same branch
Previously, in Travis, when the same branch was pushed again and the "Auto cancellation" option on the "Settings" page had been turned on (as it was for most repos), any still running builds for the same branch would be stopped in favour of starting the build for the newly pushed version of the branch.

To enable this behaviour in GH Actions, a `concurrency` configuration needs to be added to each workflow for which this should applied to.

More than anything, this is a way to be kind to GitHub by not wasting resources which they so kindly provide to us for free.

Refs:
* https://github.blog/changelog/2021-04-19-github-actions-limit-workflow-run-or-job-concurrency/
* https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#concurrency
2021-12-23 05:06:02 +01:00
jrfnl
6a7b8e3857 Composer: allow the PHPCS plugin
The `dealerdirect/phpcodesniffer-composer-installer` Composer plugin is used to register external PHPCS standards with PHPCS.

As of Composer 2.2.0, Composer plugins need to be explicitly allowed to run. This adds the necessary configuration for that.

Refs:
* https://blog.packagist.com/composer-2-2/#more-secure-plugin-execution
2021-12-23 05:05:41 +01:00
Juliette
dc2f21771c
Merge pull request #2004 from WordPress/feature/nosilenced-errors-add-function-to-list
PHP/NoSilencedErrors: add two functions to the ignore list
2021-07-29 13:23:51 +02:00
jrfnl
92c2528e82 PHP/NoSilencedErrors: add imagecreatefromwebp
... as WP now includes WebP support.
2021-07-28 18:56:01 +02:00
jrfnl
2f7d1ebef8 PHP/NoSilencedErrors: add libxml_disable_entity_loader()
... to the default "ignore" list.

The `libxml_disable_entity_loader()` function is deprecated in PHP 8.0, but a call to the function is still needed in select circumstances, in which case silencing the deprecation warning is perfectly acceptable.
2021-07-28 18:55:27 +02:00
Denis Žoljom
44e9bdde14
Merge pull request #1999 from WordPress/feature/ghactions-turn-on-error-reporting
GH Actions: turn display_errors on
2021-06-22 13:36:50 +02:00
jrfnl
a844b50f8a GH Actions: turn display_errors on
Turns out the default setting for `error_reporting` used by the SetupPHP action is `error_reporting=E_ALL & ~E_DEPRECATED & ~E_STRICT` and `display_errors` is set to `Off`.

For the purposes of CI, I'd recommend running with `E_ALL` and `display_errors=On` to ensure **all** PHP notices are shown.

In this script, error_reporting was already enabled, but the error display was not yet fixed. Sorted now.
2021-06-22 03:23:17 +02:00
Juliette
2a72b1c26d
Merge pull request #1997 from WordPress/feature/improve-bug-template
Bug report template: various improvements
2021-06-15 16:29:40 +02:00
jrfnl
75ec4e2dff Bug report template: various improvements
After the umpteenth time of getting a non-reproducible bug report (not just in this repo, mind you), I figured it may help to add some more guidance to the bug report template.

More important changes:
* Ask for the actual CLI command people have used.
* Ask for the custom ruleset used (if used).
* Give some guidance on how to find out the version numbers of the tooling used.
2021-06-15 16:08:36 +02:00
Gary Jones
9e89040631
Merge pull request #1998 from WordPress/feature/cs-get-rid-of-warnings 2021-06-15 10:18:04 +01:00
jrfnl
69caed7f20 QA: import all used classes 2021-06-15 00:46:34 +02:00
jrfnl
ae6bc021d0 QA: use fully qualified global constant references 2021-06-15 00:46:23 +02:00
jrfnl
b1a02ac423 QA: remove unnecessary assignment 2021-06-15 00:45:36 +02:00
jrfnl
4dc9ac66f7 CS: get rid of "commented out code" warnings
... which show through in PRs, even when the code in those files has not been adjusted in the PR.

There's only one such warning remaining now, which is _actual_ commented out code.
2021-06-15 00:45:15 +02:00
Denis Žoljom
41f5a9c66f
Merge pull request #1802 from WordPress/feature/move-one-object-per-class-to-core
OneObjectStructurePerFile: move from `Extra` to `Core`
2021-04-12 08:28:36 +02:00
Gary Jones
2483567a56
Merge pull request #1983 from WordPress/feature/ghactions-show-cs-violations-in-pr 2021-04-09 14:17:27 +01:00
jrfnl
88c56085b9 OneObjectStructurePerFile: move from Extra to Core
Per the discussion had on Slack about this initiated by GaryJones.
WP Core currently has 27 violations against this rule.

In `Extra` the error message was changed and downgraded to a `warning`.

Now the sniff will be added to `Core`, per this PR, the:
* Message text will still be changed a little to be clearer, but will be stricter.
* The message will be an `error` and not be downgraded to a `warning`.

To do:
- [ ] Add a rule to this effect to the handbook.
2021-04-09 12:44:32 +02:00
jrfnl
d4731efaf5 GH Actions: don't use cs2pr in quicktest
... as the `quicktest` workflow is run on `push` events, not on PRs, so displaying results in a PR is not relevant (and is done via the `test` workflow which _is_ run on `pull` events anyhow).
2021-04-09 12:39:45 +02:00
jrfnl
d710432bae GH Actions: report CS violations in the PR
The cs2pr tool will allow to display the results from an action run in checkstyle format in-line in the PR code view, which should improve usability of the workflow results.

Ref: https://github.com/staabm/annotate-pull-request-from-checkstyle
2021-04-09 12:39:45 +02:00
Gary Jones
0bb2688c53
Merge pull request #1986 from WordPress/feature/ghactions-fix-tests-on-php-8.1
GH Actions: get the tests running on PHP 8.1 (nightly)
2021-04-09 10:11:17 +01:00
jrfnl
96271f6a26 GH Actions: get the tests running on PHP 8.1 (nightly)
Letting PHPUnit read the config file causes an error on PHP 8.1 in combination with PHPUnit 7.

For now, special case the test run on PHP 8.1 and pass the only necessary config from the configuration file on via CLI arguments.
2021-04-09 04:35:51 +02:00
Gary Jones
2fdc57f70b
Merge pull request #1985 from WordPress/php-8.1/fix-incompatibility-trim-2
PHP 8.1 compatibility: fix deprecation notice [2]
2021-04-09 03:24:16 +01:00
Gary Jones
a538cdbcd0
Merge pull request #1984 from WordPress/php-8.1/fix-incompatibility-trim
PHP 8.1 compatibility: fix deprecation notice [1]
2021-04-09 03:23:35 +01:00
jrfnl
e9c4858f46 PHP 8.1 compatibility: fix deprecation notice [2]
PHP 8.1 deprecates passing `null` to PHP native functions where the parameter(s) is not explicitly nullable.

While in PHP 8.1 this is only a deprecation, it should, of course, still be fixed.

This commit contains a fix for the second of the two issues in WordPressCS found related to this so far (based on the unit tests).

Passing `null` to `trim()` is now deprecated, so more defensive coding or explicit type casting is needed.
This comes into play for the `I18nSniff::process_token()` and the `PrefixAllGlobalsSniff::process_token()` methods where the `Helper::getConfigData()` method can return either string or `null`.

Ref: https://phpcsutils.com/phpdoc/classes/PHPCSUtils-BackCompat-Helper.html#method_getConfigData
2021-04-07 17:06:18 +02:00
jrfnl
880af82fd4 PHP 8.1 compatibility: fix deprecation notice [1]
PHP 8.1 deprecates passing `null` to PHP native functions where the parameter(s) is not explicitly nullable.

While in PHP 8.1 this is only a deprecation, it should, of course, still be fixed.

This commit contains a fix for the one of the two issues in WordPressCS found related to this so far (based on the unit tests).

Passing `null` to `trim()` is now deprecated, so more defensive coding or explicit type casting is needed.
This comes into play for the `MinimumWPVersionTrait::get_wp_version_from_cli()` method where the `Helper::getCommandLineData()` method can return either string or `null`.

Ref: https://phpcsutils.com/phpdoc/classes/PHPCSUtils-BackCompat-Helper.html#method_getCommandLineData
2021-04-07 16:47:52 +02:00
Denis Žoljom
533699a3dd
Merge pull request #1982 from WordPress/feature/ghactions-dont-test-against-phpcs-4.x
GH Actions: don't test against PHPCS 4.x (yet)
2021-04-07 16:08:39 +02:00
jrfnl
7c3f949c7a GH Actions: don't test against PHPCS 4.x (yet)
As it looks like PHPCS 4.x is still quite a while away (2022 at the earliest), let's stop testing against PHPCS 4.x for the time being.

This should allow build failure reporting to be more accurate, as currently every PR has a failure on PHPCS 4.x due to a bug in some of the new code in 4.x (fix for this was pulled six months ago and still not merged).

The build against PHPCS 4.x should be re-enabled closer to the PHPCS 4.x release.

Note: PHPCSUtils will continue to test against PHPCS 4.x and will update the provided utilities ahead of time, so with a bit of luck, by the time the build against PHPCS 4.x is re-enabled, the build should largely pass thanks to the compatibility layers in PHPCSUtils.
2021-04-06 16:01:14 +02:00
Denis Žoljom
b04a7843cd
Merge pull request #1978 from WordPress/feature/escapeoutput-bugfix-fqn-function-calls
Security/EscapeOutput: bug fix - allow for basename() being fully qualified
2021-02-26 09:17:14 +01:00
jrfnl
f1a07acf5a Security/EscapeOutput: bug fix - allow for basename() being fully qualified 2021-02-25 21:29:53 +01:00