Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
a7d8199
Merge pull request #487 from Automattic/release/2.1.0
rebeccahum Jul 6, 2020
3483648
chore: Add `.gitattributes` file
GaryJones Jul 9, 2020
6d08d86
chore: Add CODEOWNERS file
GaryJones Jul 9, 2020
41ed334
Merge pull request #494 from Automattic/chore/codeowners
rebeccahum Jul 9, 2020
6eb7b0c
Merge pull request #495 from Automattic/feature/gitattributes
GaryJones Jul 9, 2020
a896729
Switch to sirbrillig/phpcs-variable-analysis
GaryJones Oct 31, 2019
bfc7fc5
Merge pull request #450 from Automattic/feature/variable-analysis
rebeccahum Jul 13, 2020
ebddcfc
Travis: change from "trusty" to "xenial"
jrfnl Jul 21, 2020
104ff07
Merge pull request #500 from Automattic/feature/update-travis-env
GaryJones Jul 21, 2020
a44e76b
Contributing: move file to `.github` directory
jrfnl Jul 21, 2020
57e4780
Contributing: improve the text
jrfnl Jul 21, 2020
8331730
Merge pull request #501 from Automattic/fix/contributing-fix-link
GaryJones Jul 21, 2020
74a0ce3
CS ruleset: minor tweaks
jrfnl Jul 21, 2020
9d1c62d
RulesetTest: fix compatibility with Windows
jrfnl Jul 21, 2020
f3944e7
Merge pull request #502 from Automattic/fix/minor-phpcs-ruleset-tweak
GaryJones Jul 21, 2020
df43dcd
Merge pull request #503 from Automattic/fix/ruleset-test-windows-compat
GaryJones Jul 21, 2020
eadda0a
DeclarationCompatibility: fix incorrect signature check for `Walker::…
jrfnl Jul 21, 2020
e523148
Merge pull request #505 from Automattic/fix/448-detect-correct-walker…
GaryJones Jul 21, 2020
baa18f4
Ruleset test script: fail the build on failing ruleset tests
jrfnl Jul 21, 2020
1a421d4
WordPressVIPMinimum: fix the failing ruleset test
jrfnl Jul 21, 2020
4aed540
RulesetTest: fix the test script to be able to handle 0 values
jrfnl Jul 21, 2020
2c70364
Merge pull request #504 from Automattic/fix/travis-not-failing-on-fai…
GaryJones Jul 22, 2020
bea4a24
RulesetTest: don't use the system default version of PHP
jrfnl Jul 22, 2020
4c5007b
Merge pull request #508 from Automattic/fix/rulesettest-dont-use-syst…
GaryJones Jul 22, 2020
1634ae2
Ruleset Tests: revert 485 and fix it
jrfnl Jul 22, 2020
26628f7
Merge pull request #509 from Automattic/fix/485-revert-and-fix-properly
GaryJones Jul 22, 2020
3e03066
Variables/RestrictedVariables: fix namespace of unit test file
jrfnl Jul 27, 2020
270045d
Contributing: remove duplicate info
jrfnl Jul 22, 2020
bc780bb
Variables/RestrictedVariables: fix the test
jrfnl Jul 27, 2020
42fb244
Test bootstrap: various minor tweaks
jrfnl Jul 27, 2020
77e4258
Merge pull request #557 from Automattic/fix/contributing-remove-dupli…
GaryJones Jul 27, 2020
f5bde12
Merge pull request #558 from Automattic/fix/test-bootstrap-various-tw…
GaryJones Jul 27, 2020
4d644cb
Merge pull request #559 from Automattic/fix/restrictedvariables-tests…
GaryJones Jul 27, 2020
35068c0
Functions/RestrictedFunctions: fix false positive on class instantiation
jrfnl Jul 27, 2020
84605b5
Merge pull request #561 from Automattic/fix/469-restrictedfunctions-f…
GaryJones Jul 27, 2020
060fcf1
Hooks/AlwaysReturnInFilter: add support for hook-ins using short arrays
jrfnl Jul 27, 2020
b61a257
RestrictedFunctions: fix false negative - functions in `config_settin…
jrfnl Jul 28, 2020
ad76879
Merge pull request #566 from Automattic/fix/restricted-functions-opca…
GaryJones Jul 28, 2020
46895e9
PreGetPosts: improve the isEarlyMainQueryCheck() method [1]
jrfnl Jul 28, 2020
82d1232
PreGetPosts: improve the isEarlyMainQueryCheck() method [2]
jrfnl Jul 28, 2020
45fd0d4
Merge pull request #565 from Automattic/fix/499-pregetposts-undefined…
GaryJones Jul 28, 2020
b0c949f
Merge pull request #563 from Automattic/fix/358-alwaysreturninfilter-…
GaryJones Jul 29, 2020
6b6cf10
Hooks/PreGetPosts: add support for hook-ins using short arrays
jrfnl Jul 28, 2020
8ff3fa9
Merge pull request #564 from Automattic/fix/358-pregetpost-support-sh…
GaryJones Jul 29, 2020
b54105f
RestrictedVariables: don't report on "use" in `isset()`
jrfnl Jul 29, 2020
cbf1525
PHPCS ruleset: forbid yoda conditions in VIPCS codebase
jrfnl Jul 30, 2020
fe6ccec
CS: change yoda conditions to non-yoda
jrfnl Jul 30, 2020
a3334db
Merge pull request #569 from Automattic/fix/568-restrictedvariable-di…
GaryJones Jul 30, 2020
00d4f35
Merge pull request #571 from Automattic/fix/no-yoda-in-own-codebase
GaryJones Jul 30, 2020
be0fb40
Tests: add code coverage configuration
jrfnl Jul 27, 2020
03697e0
Code coverage recording: add @covers tags
jrfnl Jul 27, 2020
2e141c1
Test scripts: add ability to pass additional command line arguments
jrfnl Jul 29, 2020
271708f
Merge pull request #560 from Automattic/add/code-coverage-checking
GaryJones Aug 1, 2020
307db72
Composer: Change minimum stability to stable
GaryJones Aug 29, 2020
efa778a
Merge pull request #573 from Automattic/change/minimum-stability
GaryJones Aug 29, 2020
6d0a6f1
ProperEscaping: Fix message for action attribute
GaryJones Aug 29, 2020
8069922
Docs: Update notes for releasing
GaryJones Aug 31, 2020
06ededf
Merge pull request #576 from Automattic/fix/notes-about-releasing
GaryJones Aug 31, 2020
99f7959
Merge pull request #575 from Automattic/fix/incorrect-message-for-pro…
rebeccahum Aug 31, 2020
645f7f7
Docs: Add comparisons and props for old versions
GaryJones Sep 4, 2020
612416a
Merge pull request #579 from Automattic/fix/changelog-old-updates-and…
GaryJones Sep 4, 2020
0bb1580
2.2.0 change log
GaryJones Aug 29, 2020
92fb4a4
Merge pull request #577 from Automattic/changelog/2.2.0
GaryJones Sep 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Exclude files from release archives.
# This will also make them unavailable when using Composer with `--prefer-dist`.
# If you develop for VIPCS using Composer, use `--prefer-source`.
# https://blog.madewithlove.be/post/gitattributes/
#
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.phpcs.xml.dist export-ignore
/.travis.yml export-ignore
/phpunit.xml.dist export-ignore
/.github export-ignore
/bin export-ignore
/tests export-ignore
/WordPressVIPMinimum/Tests export-ignore

#
# Auto detect text files and perform LF normalization
# http://davidlaing.com/2012/09/19/customise-your-gitattributes-to-become-a-git-ninja/
#
* text=auto

#
# The above will handle all files NOT found below
#
*.md text
*.php text
*.inc text
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# The following teams will get auto-tagged for a review.
# See https://docs.github.com/en/enterprise/2.15/user/articles/about-code-owners

* @Automattic/vipcs
54 changes: 42 additions & 12 deletions CONTRIBUTING.md → .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,24 @@ Hi, thank you for your interest in contributing to the VIP Coding Standards! We
Before reporting a bug, you should check what sniff an error is coming from.
Running `phpcs` with the `-s` flag will show the name of the sniff with each error.

Please search the repository before opening an issue to verify that the issue hasn't been reported already.

Bug reports containing a minimal code sample which can be used to reproduce the issue are highly appreciated as those are most easily actionable.

### Upstream Issues

Since VIPCS employs many sniffs that are part of PHPCS, and makes use of WordPress Coding Standards sniffs, sometimes an issue will be caused by a bug upstream and not in VIPCS itself. If the error message in question doesn't come from a sniff whose name starts with `WordPressVIPMinimum`, the issue is probably a bug in PHPCS itself, and should be [reported there](https://github.com/squizlabs/PHP_CodeSniffer/issues).
Since VIPCS employs many sniffs that are part of PHPCS, and makes use of WordPress Coding Standards sniffs, sometimes an issue will be caused by a bug upstream and not in VIPCS itself. If the error message in question doesn't come from a sniff whose name starts with `WordPressVIPMinimum`, the issue is probably an upstream bug.

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

Sniffname starts with | Report to
--- | ---
`Generic` | [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/issues/)
`PSR2` | [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/issues/)
`Squiz` | [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer/issues/)
`VariableAnalysis` | [VariableAnalysis](https://github.com/sirbrillig/phpcs-variable-analysis/issues/)
`WordPress` | [WordPressCS](https://github.com/WordPress/WordPress-Coding-Standards/issues/)
`WordPressVIPMinimum` | [VIPCS](https://github.com/Automattic/VIP-Coding-Standards/issues/) (this repo)

----

Expand Down Expand Up @@ -42,7 +55,7 @@ The sniffs and test files - not test _case_ files! - for VIPCS should be written
When writing sniffs, always remember that any `public` sniff property can be overruled via a custom ruleset by the end-user.
Only make a property `public` if that is the intended behaviour.

When you introduce new `public` sniff properties, or your sniff extends a class from which you inherit a `public` property, please don't forget to update the [public properties wiki page](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties) with the relevant details once your PR has been merged into the `develop` branch.
When you introduce new `public` sniff properties, or your sniff extends a class from which you inherit a `public` property, please don't forget to update the [public properties wiki page](https://github.com/Automattic/VIP-Coding-Standards/wiki/Custom-properties-for-VIPCS-Sniffs) with the relevant details once your PR has been merged into the `develop` branch.

## Unit Testing

Expand All @@ -61,7 +74,7 @@ N.B.: If you installed VIPCS using Composer, make sure you used `--prefer-source
If you already have PHPUnit installed on your system: Congrats, you're all set.

If not, you can navigate to the directory where the `PHP_CodeSniffer` repo is checked out and do `composer install` to install the `dev` dependencies.
Alternatively, you can [install PHPUnit](https://phpunit.de/manual/5.7/en/installation.html) as a PHAR file.
Alternatively, you can [install PHPUnit](https://phpunit.readthedocs.io/en/7.5/installation.html) as a PHAR file.

### Before running the unit tests

Expand All @@ -71,11 +84,13 @@ For the unit tests to work, you need to make sure PHPUnit can find your `PHP_Cod

The easiest way to do this is to add a `phpunit.xml` file to the root of your VIPCS installation and set a `PHPCS_DIR` environment variable from within this file. Make sure to adjust the path to reflect your local setup.
```xml
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.3/phpunit.xsd"
beStrictAboutTestsThatDoNotTestAnything="false"
bootstrap="./tests/bootstrap.php"
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.2/phpunit.xsd"
backupGlobals="true"
bootstrap="./tests/bootstrap.php"
beStrictAboutTestsThatDoNotTestAnything="false"
colors="true">
<php>
<env name="PHPCS_DIR" value="/path/to/PHP_CodeSniffer/"/>
Expand All @@ -86,7 +101,7 @@ The easiest way to do this is to add a `phpunit.xml` file to the root of your VI
### Running the unit tests

* Make sure you have registered the directory in which you installed VIPCS with PHPCS using;

```sh
phpcs --config-set installed_paths path/to/VIPCS
```
Expand All @@ -99,13 +114,13 @@ The easiest way to do this is to add a `phpunit.xml` file to the root of your VI

Expected output:
```
PHPUnit 7.5.12 by Sebastian Bergmann and contributors.
PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

........................................... 43 / 43 (100%)
.......................................... 42 / 42 (100%)

44 sniff test files generated 119 unique error codes; 0 were fixable (0%)
43 sniff test files generated 117 unique error codes; 0 were fixable (0%)

Time: 380 ms, Memory: 30.00MB
Time: 246 ms, Memory: 32.00 MB
```

### Unit Testing conventions
Expand Down Expand Up @@ -178,3 +193,18 @@ An example where it might not would be when a ruleset references a local sniff o
The `composer test` or `composer 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.

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

## Releases

- 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.
- Create a PR of `develop` <-- `changelog/x.y.z`, but do not merge until ready to release.
- 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.
- When ready to release, merge the change log PR into `develop`, then merge the `develop` into `master` PR.
- Tag the commit in `master` with the appropriate version number. Ideally, have it signed.
- Close the current milestone.
- Open a new milestone for the next release.
- If any open PRs/issues which were milestoned for this release do not make it into the release, update their milestone.
- 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).
- Write an internal P2 post.
- Open a PR to update the [Review Bot dependencies](https://github.com/Automattic/vip-go-ci/blob/master/tools-init.sh).

8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/release-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ assignees: GaryJones, rebeccahum

⚠️ DO NOT MERGE (YET) ⚠️

Please do add approvals if you agree.
[Remaining work for this Milestone](https://github.com/Automattic/VIP-Coding-Standards/milestone/X)

PR for tracking changes for the 2.x.y release. Target release date: DOW DD MMMM.
PR for tracking changes for the X.Y.Z release. Target release date: DOW DD MMMM YYYY.

- [ ] Add changelog for this release.
- [ ] Add change log for this release: PR #XXX
- [ ] Merge this PR.
- [ ] Add release tag against `master`.
- [ ] Add signed release tag against `master`.
- [ ] Close the current milestone.
- [ ] Open a new milestone for the next release.
- [ ] If any open PRs/issues which were milestoned for this release do not make it into the release, update their milestone.
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/
vendor/
composer.lock
phpcs.xml
Expand Down
12 changes: 6 additions & 6 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<rule ref="WordPress-Extra">
<exclude name="WordPress.Files.FileName"/>
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
<exclude name="WordPress.PHP.YodaConditions"/>
</rule>

<rule ref="WordPress-Docs"/>
Expand All @@ -31,16 +33,14 @@

<rule ref="PSR2.Methods.FunctionClosingBrace"/>

<!-- Disallow long array syntax -->
<!-- Disallow long array syntax. -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>

<!-- Allow short array syntax -->
<rule ref="Generic.Arrays.DisallowShortArraySyntax.Found">
<exclude name="Generic.Arrays.DisallowShortArraySyntax.Found"/>
</rule>
<!-- Disallow Yoda conditions. -->
<rule ref="Generic.ControlStructures.DisallowYodaConditions"/>

<!-- Check code for cross-version PHP compatibility. -->
<config name="testVersion" value="5.6-"/>
<config name="testVersion" value="5.4-"/>
<rule ref="PHPCompatibility">
<!-- Exclude PHP constants back-filled by PHPCS. -->
<exclude name="PHPCompatibility.PHP.NewConstants.t_finallyFound"/>
Expand Down
18 changes: 15 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: php
os: linux
dist: trusty
dist: xenial

env:
# `master` is now 3.x.
Expand All @@ -13,8 +13,6 @@ cache:
- $HOME/.cache/composer/files

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
Expand Down Expand Up @@ -69,6 +67,20 @@ jobs:
# Run PHPCS against VIPCS.
- ./bin/phpcs

# Builds which need a different distro.
- stage: test
- php: 5.5
dist: trusty
env: PHPCS_BRANCH="dev-master"
- php: 5.5
dist: trusty
env: PHPCS_BRANCH="3.5.5"
- php: 5.4
dist: trusty
env: PHPCS_BRANCH="dev-master"
- php: 5.4
dist: trusty
env: PHPCS_BRANCH="3.5.5"

before_install:
# Speed up build time by disabling Xdebug.
Expand Down
Loading