Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
60ba1c8
wp_remote_get: expand on message
GaryJones Aug 18, 2019
13bcfb4
append: Remove error for use of append in VIP Go
GaryJones Aug 18, 2019
cba8f2d
Merge pull request #438 from Automattic/add/wp-remote-get-message
rebeccahum Aug 19, 2019
b3e134c
Merge pull request #439 from Automattic/fix/remove-error-for-append
rebeccahum Aug 19, 2019
fc0ae5f
WordPress-VIP-Go: Downgrade to "Warning" level for AdminBarRemovalSni…
rebeccahum Aug 27, 2019
37c5059
Merge pull request #443 from Automattic/rebecca/edit_admin_removal_go
rebeccahum Aug 28, 2019
5a88cb0
Add get_page_by_path() warning to VIP restricted function sniffs.
Sep 13, 2019
d8fbf90
Use new sniff WordPress.DateTime.RestrictedFunctions
kevinfodness Nov 21, 2019
89d7b35
Merge pull request #453 from kevinfodness/hotfix/deprecated-timezone-…
rebeccahum Dec 2, 2019
38ec339
Allow short array syntax and fix tests failing for WordPress.Arrays.A…
rebeccahum Dec 2, 2019
bf8558a
Merge pull request #447 from jenkoian/add-get-page-by-path-to-restric…
rebeccahum Dec 3, 2019
8d8812b
Allow for short array syntax (#454)
GaryJones Dec 9, 2019
136e7bc
Update Bug report issue template for develop check
rebeccahum Jan 29, 2020
dc83214
IncludingFileSniff: Add get_parent_theme_file_path to safelist of pat…
rebeccahum Jan 31, 2020
15a1cd9
RestrictedFunctions: Add stats_get_csv() along with unit tests
rebeccahum Jan 31, 2020
0faf12f
IncludingFileSniff: Add get_parent_theme_file_path to safelist
rebeccahum Feb 3, 2020
4dfac5d
Merge pull request #463 from Automattic/fix_462
rebeccahum Feb 5, 2020
78fc9ba
Merge branch 'develop' into fix_461
rebeccahum Feb 5, 2020
478f56c
Merge pull request #464 from Automattic/fix_461
rebeccahum Feb 6, 2020
0fab6ac
Travis: rearrange, and fix warnings and infos
GaryJones Apr 17, 2020
59383c9
Travis: Change install: false to install: skip
GaryJones Apr 17, 2020
65b937f
CS: Add missing trailing comma
GaryJones Apr 17, 2020
8cc2c8e
RestrictedFunctions: Remove get_super_admins rule on Go ruleset
rebeccahum Jul 2, 2020
f726c12
Merge pull request #483 from Automattic/rebecca/remove_super_admin_ru…
GaryJones Jul 3, 2020
f5d3437
Dependencies: Update versions
GaryJones Jul 3, 2020
b537522
Switch to Generic.VersionControl.GitMergeConflict
GaryJones Jul 3, 2020
6d739b6
Merge pull request #486 from Automattic/feature/remove-merge-conflict…
rebeccahum Jul 3, 2020
e1d50c7
Merge pull request #484 from Automattic/feature/update-dependency-ver…
rebeccahum Jul 3, 2020
2c30904
Ruleset Tests: Avoid issue with trigger_error()
GaryJones Jul 3, 2020
fe60d9f
Merge pull request #485 from Automattic/fix/ruleset-tests
rebeccahum Jul 3, 2020
4a8e464
HTMLExecutingFunctions: Add more functions
GaryJones Aug 18, 2019
a2ea440
HTMLExecutingFunctions: Add further test cases
GaryJones Jul 3, 2020
48e83cc
Merge pull request #437 from Automattic/fix/xss-js
rebeccahum Jul 3, 2020
d9a7529
Travis: test against PHP 7.4, not snapshot
GaryJones Dec 9, 2019
47a441e
Merge pull request #455 from Automattic/feature/travis-php-7.4
rebeccahum Jul 4, 2020
94536ba
Add release template
GaryJones Jul 6, 2020
f477491
Update .github/ISSUE_TEMPLATE/release-template.md
GaryJones Jul 6, 2020
27e9363
Merge pull request #489 from Automattic/feature/release-template
GaryJones Jul 6, 2020
9ae3696
Travis: Use PHPUnit 7 with PHP 8
GaryJones Jul 6, 2020
d61364a
Travis: Expand supported PHP down to 5.4
GaryJones Jul 6, 2020
d4a4e1c
Merge pull request #490 from Automattic/fix/travis-php-8
GaryJones Jul 6, 2020
f4ae841
Merge pull request #491 from Automattic/experiment/travis-php-5.4
GaryJones Jul 6, 2020
4a8cb7d
Docs: Changelog for 2.1.0
GaryJones Jul 5, 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
4 changes: 4 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

Expand Down Expand Up @@ -50,3 +53,4 @@ Use `php -v` and `composer show` to get versions.
## Tested Against `master` branch?

- [ ] I have verified the issue still exists in the `master` branch of VIPCS.
- [ ] I have verified the issue still exists in the `develop` branch of VIPCS.
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/enhancement.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
name: Enhancement
about: Suggest an improvement for this project
title: ''
labels: ''
assignees: ''

---

Expand Down
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/release-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
name: Release template
about: Internally used for new releases
title: Release 2.x.y
labels: 'Type: Maintenance'
assignees: GaryJones, rebeccahum

---

⚠️ DO NOT MERGE (YET) ⚠️

Please do add approvals if you agree.

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

- [ ] Add changelog for this release.
- [ ] Merge this PR.
- [ ] Add 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.
- [ ] Write a Lobby post.
- [ ] Write an internal P2 post.
- [ ] Open PR to update [Review Bot dependencies](https://github.com/Automattic/vip-go-ci/blob/master/tools-init.sh).
5 changes: 5 additions & 0 deletions .phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
<!-- 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>

<!-- Check code for cross-version PHP compatibility. -->
<config name="testVersion" value="5.6-"/>
<rule ref="PHPCompatibility">
Expand Down
81 changes: 48 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,27 @@
dist: xenial

cache:
directories:
- $HOME/.cache/composer/files

language:
- php

before_install:
# Speed up build time by disabling Xdebug.
# https://johnblackbourn.com/reducing-travis-ci-build-times-for-wordpress-projects/
# https://twitter.com/kelunik/status/954242454676475904
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'

install:
- composer require squizlabs/php_codesniffer:"$PHPCS_BRANCH" --update-no-dev --no-suggest --no-scripts
- composer install --dev --no-suggest

script:
# Run the unit tests.
- ./bin/unit-tests

# Run ruleset tests.
- ./bin/ruleset-tests
language: php
os: linux
dist: trusty

env:
# `master` is now 3.x.
- PHPCS_BRANCH="dev-master"
# Lowest supported release in the 3.x series with which VIPCS is compatible.
- PHPCS_BRANCH="3.3.1"
- PHPCS_BRANCH="3.5.5"

cache:
directories:
- $HOME/.cache/composer/files

php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3
- "7.4snapshot"
- 7.4
- "nightly"

# Rather than a `matrix` property, we use build stages. This allows early
# build failure for basic linting and sniffing issues.
Expand All @@ -49,15 +34,15 @@ stages:

jobs:
allow_failures:
- php: "7.4snapshot"
- php: "nightly"
include:

- stage: lint
php: 7.3
php: 7.4
env: PHPCS_BRANCH="dev-master"
before_install: phpenv config-rm xdebug.ini || echo 'No xdebug config.'
install: false
cache: false
install: skip
cache: skip
script:
# Lint the PHP files against parse errors.
- ./bin/php-lint
Expand All @@ -76,12 +61,42 @@ jobs:
- libxml2-utils

- stage: sniff
php: 7.3
php: 7.4
env: PHPCS_BRANCH="dev-master"
before_install: phpenv config-rm xdebug.ini || echo 'No xdebug config.'
install: composer install --dev --no-suggest
install: composer install --no-suggest
script:
# Run PHPCS against VIPCS.
- ./bin/phpcs


before_install:
# Speed up build time by disabling Xdebug.
# https://johnblackbourn.com/reducing-travis-ci-build-times-for-wordpress-projects/
# https://twitter.com/kelunik/status/954242454676475904
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'

# On stable PHPCS versions, allow for PHP deprecation notices.
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
- |
if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Sniff" && $PHPCS_BRANCH != "dev-master" ]]; then
echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
fi

install:
- composer require squizlabs/php_codesniffer:"$PHPCS_BRANCH" --no-update --no-suggest --no-scripts
- |
if [[ $TRAVIS_PHP_VERSION == "nightly" ]]; then
# PHPUnit 7.x does not allow for installation on PHP 8, so ignore platform
# requirements to get PHPUnit 7.x to install on nightly.
composer install --ignore-platform-reqs --no-suggest
else
composer install --no-suggest
fi

script:
# Run the unit tests.
- ./bin/unit-tests

# Run ruleset tests.
- ./bin/ruleset-tests
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,37 @@ All notable changes to this project will be documented in this file.

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).

## [2.1.0] - 2020-07-07

Bumps requirements to PHPCS 3.5.5+ and WPCS 2.3.0+.

### Added

- `get_page_by_path()` restricted function warning, to suggest `wpcom_vip_get_page_by_path()` function.
- `stats_get_csv()` restricted function error, since this is a Jetpack-only function.
- Expanded list of HTMLExecutingFunctions to include `after`, `appendTo`, `before`, `insertAfter`, `insertBefore`, `prepend`, `prependTo`, `replaceAll` and `replaceWith`.
- Support PHP 5.4+ (down from 5.6+).
- PHP 8 nightly testing.

### Changed

- Expand message for `wp_remote_get()` usage.
- Downgrade `append()` usage violation from Error to Warning for VIP Go, to be consistent with the other HTMLExecutingFunctions.
- Downgrade AdminBarRemoval sniff from Error to Warning for VIP Go.
- Add `get_parent_theme_file_path()` to safelist of path functions for `WordPressVIPMinimum.Files.IncludingFile` sniff.
- Allow short array syntax and fix tests within the VIPCS own coding standards.
- Update issue templates.

### Fixed

- Use new `WordPress.DateTime.RestrictedFunctions` sniff instead of deprecated `WordPress.WP.TimezoneChange`.
- Fixed warnings and information items in Travis.

### Removed

- `get_super_admins()` restricted function rule for VIP Go.
- `WordPressVIPMinimum.VersionControl.MergeConflict` sniff in favour of `Generic.VersionControl.GitMergeConflict`.

## [2.0.0] - 2019-07-12

This release switches from having WPCS `1.*` as a dependency, to WPCS `2.*`. It is not compatible with WPCS `1.*`.
Expand Down Expand Up @@ -367,5 +398,6 @@ This release contains breaking changes.
- `wpcom_vip_get_page_by_path` from `WordPressVIPMinimum.VIP.RestrictedFunctions`
- Version check for PHP 7 or less in `WordPressVIPMinimum.Variables.VariableAnalysis` unit test since tests are not failing anymore.

[2.1.0]: https://github.com/Automattic/VIP-Coding-Standards/compare/2.0.0...2.1.0
[2.0.0]: https://github.com/Automattic/VIP-Coding-Standards/compare/1.0.0...2.0.0
[1.0.0]: https://github.com/Automattic/VIP-Coding-Standards/compare/0.4.0...1.0.0
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ Go to https://wpvip.com/documentation/phpcs-review-feedback/ to learn about why

## Minimal requirements

* [PHPCS 3.3.1+](https://github.com/squizlabs/PHP_CodeSniffer/releases)
* [WPCS 2.*](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/releases)
* PHP 5.4+
* [PHPCS 3.5.5+](https://github.com/squizlabs/PHP_CodeSniffer/releases)
* [WPCS 2.3.0+](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/releases)

## Installation

Expand All @@ -31,7 +32,7 @@ We recommend the [PHP_CodeSniffer Standards Composer Installer Plugin](https://g

Alternatively, you should register the standard to PHPCS by appending the VIPCS directory to the end of the installed paths. e.g.

`phpcs --config-set installed_paths [/path/to/wpcsstandard],[path/to/vipcsstandard],etc`
`phpcs --config-set installed_paths /path/to/wpcsstandard,path/to/vipcsstandard,etc.`

## Contribution

Expand Down
36 changes: 16 additions & 20 deletions WordPress-VIP-Go/ruleset-test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ function foo_bar_foo() {
}

// WordPressVIPMinimum.UserExperience.AdminBarRemoval
add_filter( 'show_admin_bar', '__return_false' ); // Error.
add_filter( 'show_admin_bar', '__return_false' ); // Warning.
add_filter( 'show_admin_bar', '__return_true' ); // Ok.
show_admin_bar( false ); // Error.
show_admin_bar( false ); // Warning.
show_admin_bar( true ); // Ok.
add_filter( 'show_admin_bar', 'my_own_return_false' ); // Error.
add_filter( 'show_admin_bar', 'my_own_return_false' ); // Warning.
echo '<style type="text/css">
#wpadminbar {
visibility: hidden; /* Error. */
Expand All @@ -232,19 +232,19 @@ echo '<style type="text/css">
</style>';
?> <style type="text/css">
#wpadminbar {
visibility: hidden; /* Error. */
display: none; /* Error. */
opacity: 0; /* Error. */
visibility: hidden; /* Warning. */
display: none; /* Warning. */
opacity: 0; /* Warning. */
}
#not-wpadminbar {
visibility: hidden; /* OK. */
display: none; /* OK. */
opacity: 0; /* OK. */
}
.show-admin-bar {
visibility: hidden; /* Error. */
display: none; /* Error. */
opacity: 0; /* Error. */
visibility: hidden; /* Warning. */
display: none; /* Warning. */
opacity: 0; /* Warning. */
}
</style> <?php

Expand Down Expand Up @@ -353,7 +353,7 @@ opcache_compile_file( $test_script ); // Error.
opcache_​is_​script_​cached( 'test_script.php' ); // Error.
opcache_​get_​status(); // Error.
opcache_​get_​configuration(); // Error.
get_super_admins(); // Error.
get_super_admins(); // OK.
wpcom_vip_irc(); // Error.
flush_rewrite_rules(); // Error.
$wp_rewrite->flush_rules(); // Error.
Expand Down Expand Up @@ -510,7 +510,7 @@ $query_args = array(
// WordPressVIPMinimum.Security.EscapingVoidReturnFunctions.Found
esc_js( _deprecated_argument() ); // Error.
esc_js( _deprecated_constructor() ); // Error.
esc_js( _deprecated_file() ); // Error.
// esc_js( _deprecated_file() ); // Error.
esc_js( _deprecated_function() ); // Error.
esc_js( _deprecated_hook() ); // Error.
esc_js( _doing_it_wrong() ); // Error.
Expand Down Expand Up @@ -567,12 +567,8 @@ $_SERVER['HTTP_X_FORWARDED_FOR']; // Error.
$_SERVER["REMOTE_ADDR"]; // Error.
// phpcs:enable WordPress.Security.ValidatedSanitizedInput.InputNotValidated,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized

// WordPressVIPMinimum.VersionControl.MergeConflict
function is_prime( $n ) {
if ( 2 === $n ) {
}
//phpcs:ignore Generic.PHP.Syntax.PHPSyntax
======= // Error.
if ( $n % 2 === 0 ) {
}
}
// Generic.VersionControl.GitMergeConflict
?>
<<<<<<< HEAD // Error.

>>>>>>> // Error.
30 changes: 15 additions & 15 deletions WordPress-VIP-Go/ruleset-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,6 @@
181 => 1,
187 => 1,
188 => 1,
221 => 1,
223 => 1,
225 => 1,
228 => 1,
229 => 1,
230 => 1,
235 => 1,
236 => 1,
237 => 1,
245 => 1,
246 => 1,
247 => 1,
252 => 1,
255 => 1,
256 => 1,
Expand All @@ -56,7 +44,6 @@
353 => 1,
354 => 1,
355 => 1,
356 => 1,
357 => 1,
358 => 1,
359 => 1,
Expand Down Expand Up @@ -111,7 +98,7 @@
507 => 1,
511 => 1,
512 => 1,
513 => 1,
// 513 => 1,
514 => 1,
515 => 1,
516 => 1,
Expand All @@ -128,7 +115,8 @@
565 => 1,
566 => 1,
567 => 1,
575 => 1,
572 => 1,
574 => 1,
],
'warnings' => [
4 => 1,
Expand Down Expand Up @@ -197,6 +185,18 @@
208 => 1,
212 => 1,
217 => 1,
221 => 1,
223 => 1,
225 => 1,
228 => 1,
229 => 1,
230 => 1,
235 => 1,
236 => 1,
237 => 1,
245 => 1,
246 => 1,
247 => 1,
265 => 1,
269 => 1,
273 => 1,
Expand Down
Loading