Skip to content

Commit

Permalink
Merge pull request #488 from Automattic/release/2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryJones authored Jul 7, 2020
2 parents fc02f49 + 4a8cb7d commit 03e75dd
Show file tree
Hide file tree
Showing 27 changed files with 345 additions and 292 deletions.
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

0 comments on commit 03e75dd

Please sign in to comment.