Skip to content

Commit 6060fe5

Browse files
authored
Merge pull request #794 from Automattic/release/3.0.0
2 parents 008bf9a + fad2290 commit 6060fe5

7 files changed

Lines changed: 114 additions & 52 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 62 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ Since VIPCS employs many sniffs that are part of PHPCS, and makes use of WordPre
1717

1818
To determine where best to report the bug, use the first part of the sniff name:
1919

20-
Sniffname starts with | Report to
20+
Sniff name starts with | Report to
2121
--- | ---
2222
`Generic` | [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/issues/)
2323
`PSR2` | [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/issues/)
2424
`Squiz` | [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/issues/)
25+
`Universal` | [PHPCSExtra](https://github.com/PHPCSStandards/PHPCSExtra/issues/)
2526
`VariableAnalysis` | [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis/issues/)
2627
`WordPress` | [WordPressCS](https://github.com/WordPress/WordPress-Coding-Standards/issues/)
2728
`WordPressVIPMinimum` | [VIPCS](https://github.com/Automattic/VIP-Coding-Standards/issues/) (this repo)
@@ -44,7 +45,7 @@ After `composer install`, you can do:
4445

4546
## Branches
4647

47-
Ongoing development will be done in feature branches then pulled against the `develop` branch and follows a typical _git-flow_ approach, where merges to `master` only happen when a new release is made.
48+
Ongoing development will be done in feature branches then pulled against the `develop` branch and follows a typical _git-flow_ approach, where merges to `main` only happen when a new release is made.
4849

4950
To contribute an improvement to this project, fork the repo and open a pull request to the relevant branch. Alternatively, if you have push access to this repo, create a feature branch prefixed by `fix/` (followed by the issue number) or `add/` and then open a PR from that branch to the default (`develop`) branch.
5051

@@ -90,7 +91,7 @@ The easiest way to do this is to add a `phpunit.xml` file to the root of your VI
9091
<?xml version="1.0" encoding="UTF-8"?>
9192
<phpunit
9293
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
93-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.2/phpunit.xsd"
94+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
9495
backupGlobals="true"
9596
bootstrap="./tests/bootstrap.php"
9697
beStrictAboutTestsThatDoNotTestAnything="false"
@@ -112,47 +113,52 @@ The easiest way to do this is to add a `phpunit.xml` file to the root of your VI
112113
* To run the unit tests:
113114

114115
```sh
115-
phpunit --filter WordPressVIPMinimum $PHPCS_DIR/tests/AllTests.php
116+
composer test
116117
```
117118

118119
Expected output:
119120
```
120121
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.
121122

122-
.......................................... 42 / 42 (100%)
123+
........................................ 40 / 40 (100%)
123124

124-
43 sniff test files generated 117 unique error codes; 0 were fixable (0%)
125+
45 sniff test files generated 175 unique error codes; 0 were fixable (0%)
125126

126-
Time: 246 ms, Memory: 32.00 MB
127+
Time: 150 ms, Memory: 20.00 MB
128+
129+
OK (40 tests, 0 assertions)
127130
```
128131
129132
### Unit Testing conventions
130133
131-
If you look inside the `WordPressVIPMinimum/Tests` subdirectory, you'll see the structure mimics the `WordPressVIPMinimum/Sniffs` subdirectory structure. For example, the `WordPressVIPMinimum/Sniffs/VIP/WPQueryParams.php` sniff has its unit test class defined in `WordPressVIPMinimum/Tests/VIP/WPQueryParamsUnitTest.php` which checks the `WordPressVIPMinimum/Tests/VIP/WPQueryParamsUnitTest.inc` test case file. See the file naming convention?
134+
If you look inside the `WordPressVIPMinimum/Tests` subdirectory, you'll see the structure mimics the `WordPressVIPMinimum/Sniffs` subdirectory structure. For example, the `WordPressVIPMinimum/Sniffs/Performance/WPQueryParams.php` sniff has its unit test class defined in `WordPressVIPMinimum/Tests/Performance/WPQueryParamsUnitTest.php` which checks the `WordPressVIPMinimum/Tests/Performance/WPQueryParamsUnitTest.inc` test case file. See the file naming convention?
132135
133-
Lets take a look at what's inside `WPQueryParamsUnitTest.php`:
136+
Let's take a look at what's inside `WPQueryParamsUnitTest.php`:
134137
135138
```php
136139
...
137-
namespace WordPressVIPMinimum\Tests\VIP;
140+
namespace WordPressVIPMinimum\Tests\Performance;
138141
139142
use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
140143
141144
/**
142145
* Unit test class for the WP_Query params sniff.
146+
*
147+
* @covers \WordPressVIPMinimum\Sniffs\Performance\WPQueryParamsSniff
143148
*/
144149
class WPQueryParamsUnitTest extends AbstractSniffUnitTest {
145150
146151
/**
147152
* Returns the lines where errors should occur.
148153
*
149-
* @return array <int line number> => <int number of errors>
154+
* @return array<int, int> Key is the line number, value is the number of expected errors.
150155
*/
151156
public function getErrorList() {
152-
return array(
157+
return [
153158
5 => 1,
154159
17 => 1,
155-
);
160+
31 => 1,
161+
];
156162
}
157163
...
158164
```
@@ -161,24 +167,35 @@ Also note the class name convention. The method `getErrorList()` MUST return an
161167
If you run:
162168

163169
```sh
164-
$ cd /path-to-cloned/phpcs
165-
$ ./bin/phpcs --standard=WordPressVIPMinimum -s --sniffs=WordPressVIPMinimum.VIP.WPQueryParams /path/to/WordPressVIPMinimum/Tests/VIP/WPQueryParamsUnitTest.inc
166-
...
167-
E 1 / 1 (100%)
168-
169-
170-
171-
FILE: /path/to/vipcs/WordPressVIPMinimum/Tests/VIP/WPQueryParamsUnitTest.inc
172-
--------------------------------------------------------------------------------------------------------------------------------
173-
FOUND 2 ERRORS AND 2 WARNINGS AFFECTING 4 LINES
174-
--------------------------------------------------------------------------------------------------------------------------------
175-
4 | WARNING | Using `post__not_in` should be done with caution. (WordPressVIPMinimum.VIP.WPQueryParams.post__not_in)
176-
5 | ERROR | Setting `suppress_filters` to `true` is probihited.
177-
| | (WordPressVIPMinimum.VIP.WPQueryParams.suppressFiltersTrue)
178-
11 | WARNING | Using `post__not_in` should be done with caution. (WordPressVIPMinimum.VIP.WPQueryParams.post__not_in)
179-
17 | ERROR | Setting `suppress_filters` to `true` is probihited.
180-
| | (WordPressVIPMinimum.VIP.WPQueryParams.suppressFiltersTrue)
181-
--------------------------------------------------------------------------------------------------------------------------------
170+
$ cd /path/to/vipcs
171+
$ ./vendor/bin/phpcs --standard=WordPressVIPMinimum -s --sniffs=WordPressVIPMinimum.Performance.WPQueryParams WordPressVIPMinimum/Tests/Performance/WPQueryParamsUnitTest.inc
172+
173+
FILE: /path/to/vipcs/WordPressVIPMinimum/Tests/Performance/WPQueryParamsUnitTest.inc
174+
------------------------------------------------------------------------------------------------------------------------------------------------------
175+
FOUND 3 ERRORS AND 5 WARNINGS AFFECTING 8 LINES
176+
------------------------------------------------------------------------------------------------------------------------------------------------------
177+
4 | WARNING | Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see
178+
| | https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
179+
| | (WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in)
180+
5 | ERROR | Setting `suppress_filters` to `true` is prohibited.
181+
| | (WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters)
182+
11 | WARNING | Using exclusionary parameters, like post__not_in, in calls to get_posts() should be done with caution, see
183+
| | https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
184+
| | (WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in)
185+
17 | ERROR | Setting `suppress_filters` to `true` is prohibited.
186+
| | (WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters)
187+
21 | WARNING | Using exclusionary parameters, like exclude, in calls to get_posts() should be done with caution, see
188+
| | https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
189+
| | (WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude)
190+
29 | WARNING | Using exclusionary parameters, like exclude, in calls to get_posts() should be done with caution, see
191+
| | https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
192+
| | (WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude)
193+
30 | WARNING | Using exclusionary parameters, like exclude, in calls to get_posts() should be done with caution, see
194+
| | https://wpvip.com/documentation/performance-improvements-by-removing-usage-of-post__not_in/ for more information.
195+
| | (WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude)
196+
31 | ERROR | Setting `suppress_filters` to `true` is prohibited.
197+
| | (WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters)
198+
------------------------------------------------------------------------------------------------------------------------------------------------------
182199
....
183200
```
184201
You'll see the line number and number of ERRORs we need to return in the `getErrorList()` method.
@@ -189,23 +206,26 @@ The `--sniffs=...` directive limits the output to the sniff you are testing.
189206

190207
The ruleset tests, previously named here as _integration tests_, are our way of ensuring that _rulesets_ do check for the violations we expect them to.
191208

192-
An example where it might not would be when a ruleset references a local sniff or a sniff from upstream (WPCS or PHPCS), but that the violation code, sniff name or category name has changed. Without a ruleset test, this would go unnoticed.
209+
An example where it might not would be when a ruleset references a local sniff or a sniff from upstream (WordPressCS or PHPCS), but that the violation code, sniff name or category name has changed. Without a ruleset test, this would go unnoticed.
193210

194-
The `composer check` or `composer test-ruleset` commands run the `ruleset-test.php` files (one for each standard), which internally run `phpcs` against the "dirty" test files (`ruleset-test.inc`), and looks out for a known number of errors, warnings, and messages on each line. This is then compared against the expected errors, warnings and messages to see if there are any missing or unexpected violations or difference in messages.
211+
The `composer check` or `composer test-ruleset` commands run the `ruleset-test.php` files (one for each ruleset), which internally run `phpcs` against the "dirty" test files (`ruleset-test.inc`), and looks out for a known number of errors, warnings, and messages on each line. This is then compared against the expected errors, warnings, and messages to see if there are any missing or unexpected violations or difference in messages.
195212

196213
When adding or changing a sniff, the ruleset test files should be updated to match.
197214

198215
## Releases
199216

200-
- In a `changelog/x.y.z` branch off of `develop`, update the `CHANGELOG.md` with a list of all of the changes following the keepachangelog.com format. Include PR references and GitHub username props.
201-
- Create a PR of `develop` <-- `changelog/x.y.z`, but do not merge until ready to release.
202-
- Create a PR of `master` <-- `develop`, and copy-paste the [`release-template.md`](https://github.com/Automattic/VIP-Coding-Standards/blob/develop/.github/ISSUE_TEMPLATE/release-template.md) contents.
203-
- When ready to release, merge the change log PR into `develop`, then merge the `develop` into `master` PR.
204-
- Tag the commit in `master` with the appropriate version number. Ideally, have it signed.
205-
- Close the current milestone.
217+
- Create a `release/x.y.z` branch off of `develop`.
218+
- In a `release/x.y.z-changelog` branch off of `release/x.y.z`, update the `CHANGELOG.md` with a list of all of the changes following the keepachangelog.com format. Include PR references and GitHub username props.
219+
- Create a PR of `release/x.y.z` <-- `release/x.y.z-changelog`, but do not merge until ready to release.
220+
- Create any other last-minute PRs as necessary, such as documentation updates, against the release branch.
221+
- When ready to release, merge the changelog and other branches into `release/x.y.z`.
222+
- Create a PR of `main` <-- `release/x.y.z`, and copy-paste the [`release-template.md`](https://github.com/Automattic/VIP-Coding-Standards/blob/develop/.github/ISSUE_TEMPLATE/release-template.md) contents.
223+
- When ready to release, merge `release/x.y.z` into `main`. Undelete the release branch after merging.
224+
- Tag the commit in `main` with the appropriate version number. Ideally, have it signed.
206225
- Open a new milestone for the next release.
207226
- If any open PRs/issues which were milestoned for this release do not make it into the release, update their milestone.
208-
- Write a Lobby post to inform VIP customers about the release, including the date when the Review Bot will be updated (usually about 1.5 weeks after the VIPCS release).
227+
- Close the current milestone.
228+
- Create a PR of `develop` <-- `release/x.y.z` and merge in when ready.
229+
- Write a Lobby post to inform VIP customers about the release, including the date when the VIP Code Analysis Bot will be updated (usually about 2 weeks after the VIPCS release).
209230
- Write an internal P2 post.
210-
- Open a PR to update the [Review Bot dependencies](https://github.com/Automattic/vip-go-ci/blob/master/tools-init.sh).
211-
231+
- Open a PR to update the [VIP Code Analysis bot dependencies](https://github.com/Automattic/vip-go-ci/blob/master/tools-init.sh).

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Use `php -v` and `composer show` to get versions.
5454

5555
<!-- Add any other context about the problem here. -->
5656

57-
## Tested Against `master` branch?
57+
## Tested Against `main` branch?
5858

59-
- [ ] I have verified the issue still exists in the `master` branch of VIPCS.
59+
- [ ] I have verified the issue still exists in the `main` branch of VIPCS.
6060
- [ ] I have verified the issue still exists in the `develop` branch of VIPCS.

.github/ISSUE_TEMPLATE/release-template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ assignees: GaryJones, rebeccahum
1313

1414
PR for tracking changes for the X.Y.Z release. Target release date: DOW DD MMMM YYYY.
1515

16-
- [ ] Scan WordPress (or just wp-admin folder) with prior version and compare results against new release for potential new bugs.
16+
- [ ] Scan WordPress (or just wp-admin folder) with prior version and compare results against new release for potential new bugs.
1717
- [ ] Add change log for this release: PR #XXX
1818
- [ ] Double-check whether any dependencies need bumping.
1919
- [ ] Merge this PR.
20-
- [ ] Add signed release tag against `master`.
20+
- [ ] Add signed release tag against `main`.
2121
- [ ] Close the current milestone.
2222
- [ ] Open a new milestone for the next release.
2323
- [ ] If any open PRs/issues which were milestoned for this release do not make it into the release, update their milestone.

.github/workflows/quicktest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: Quicktest
22

33
on:
4-
# Run on pushes, including merges, to all branches except `master`.
4+
# Run on pushes, including merges, to all branches except `main`.
55
push:
66
branches-ignore:
7-
- master
7+
- main
88
paths-ignore:
99
- '**.md'
1010
# Allow manually triggering the workflow.

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: Test
22

33
on:
4-
# Run on pushes to `master` and on all pull requests.
4+
# Run on pushes to `main` and on all pull requests.
55
# Prevent the "push" build from running when there are only irrelevant changes.
66
push:
77
branches:
8-
- master
8+
- main
99
paths-ignore:
1010
- '**.md'
1111
pull_request:

CHANGELOG.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,48 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [3.0.0] - 2023-09-05
8+
9+
Props: @GaryJones, @jrfnl
10+
11+
This release requires [WordPressCS 3.0.0](https://github.com/WordPress/WordPress-Coding-Standards/releases/tag/3.0.0). It is not compatible with WordPressCS 2.x. Users should read the [WordPressCS 3.0 upgrade guide for end-users](https://github.com/WordPress/WordPress-Coding-Standards/wiki/Upgrade-Guide-to-WordPressCS-3.0.0-for-ruleset-maintainers).
12+
13+
Increases requirements for PHPCS from 3.7.1 to 3.7.2.
14+
15+
The tagged releases branch is now `main` instead of `master`.
16+
17+
### Added
18+
- [#777](https://github.com/Automattic/VIP-Coding-Standards/pull/777): 3.0: start using PHPCSUtils.
19+
- [#779](https://github.com/Automattic/VIP-Coding-Standards/pull/779): 3.0: support WordPressCS 3.0.
20+
21+
## Changed
22+
- [#780](https://github.com/Automattic/VIP-Coding-Standards/pull/780): Performance/WPQueryParams: defer to the parent sniff.
23+
- Two error codes changed:
24+
- `WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn` is now `WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_post__not_in`.
25+
- `WordPressVIPMinimum.Performance.WPQueryParams.SuppressFiltersTrue` is now `WordPressVIPMinimum.Performance.WPQueryParams.SuppressFilters_suppress_filters`.
26+
27+
### Removed
28+
- [#774](https://github.com/Automattic/VIP-Coding-Standards/pull/774): Performance/BatcacheWhitelistedParams: remove the sniff.
29+
- [#775](https://github.com/Automattic/VIP-Coding-Standards/pull/775): Compatibility/Zoninator: remove the sniff.
30+
- [#776](https://github.com/Automattic/VIP-Coding-Standards/pull/776): Variables/VariableAnalysis: remove the sniff.
31+
32+
### Fixed
33+
- [#784](https://github.com/Automattic/VIP-Coding-Standards/pull/784): Performance/WPQueryParams: prevent false positives for `'exclude'` with `get_users()`.
34+
- [#788](https://github.com/Automattic/VIP-Coding-Standards/pull/788): Security/Mustache: prevent false positives on block editor templates.
35+
36+
### Maintenance
37+
- [#778](https://github.com/Automattic/VIP-Coding-Standards/pull/778): CS: improve use statements.
38+
- [#781](https://github.com/Automattic/VIP-Coding-Standards/pull/781): Performance/NoPaging: add extra tests.
39+
- [#782](https://github.com/Automattic/VIP-Coding-Standards/pull/782): GH Actions: minor tweaks to the composer options used.
40+
- [#783](https://github.com/Automattic/VIP-Coding-Standards/pull/783): Hooks/AlwaysReturnInFilter: remove redundant condition.
41+
- [#785](https://github.com/Automattic/VIP-Coding-Standards/pull/785): Docs: remove redundant `@package` tags.
42+
- [#786](https://github.com/Automattic/VIP-Coding-Standards/pull/786): Add PHPStan to QA checks.
43+
- [#787](https://github.com/Automattic/VIP-Coding-Standards/pull/787): GH Actions: tweak the way the PHPCS/WPCS versions are set.
44+
- [#789](https://github.com/Automattic/VIP-Coding-Standards/pull/789): Updates related to branch rename from `master` to `main`.
45+
- [#790](https://github.com/Automattic/VIP-Coding-Standards/pull/790): PHPUnit: Use 7.5 schema.
46+
- [#791](https://github.com/Automattic/VIP-Coding-Standards/pull/791): Docs: Update `CONTRIBUTING.md`.
47+
48+
749
## [2.3.4] - 2023-07-05
850

951
Props: kshaner, GaryJones, jrfnl, yolih
@@ -632,7 +674,7 @@ Initial release.
632674

633675
Props: david-binda, pkevan.
634676

635-
677+
[3.0.0]: https://github.com/Automattic/VIP-Coding-Standards/compare/2.3.4...3.0.0
636678
[2.3.4]: https://github.com/Automattic/VIP-Coding-Standards/compare/2.3.3...2.3.4
637679
[2.3.3]: https://github.com/Automattic/VIP-Coding-Standards/compare/2.3.2...2.3.3
638680
[2.3.2]: https://github.com/Automattic/VIP-Coding-Standards/compare/2.3.1...2.3.2

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.2/phpunit.xsd"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
55
backupGlobals="true"
66
bootstrap="./tests/bootstrap.php"
77
beStrictAboutTestsThatDoNotTestAnything="false"

0 commit comments

Comments
 (0)