Skip to:
Content

BuddyPress.org

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#7926 closed enhancement (fixed)

Automated linting for PHP versions

Reported by: boonebgorges's profile boonebgorges Owned by: netweb's profile netweb
Milestone: 4.0 Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: has-patch commit
Cc:

Description

On a handful of occasions over the last few releases, we've included syntax that is incompatible with a version of PHP that we claim to support. See eg #7925. We could help to avoid this by adding some linting to our Travis CI framework.

Here's one possible approach: https://hakre.wordpress.com/2015/11/10/linting-php-files-in-parallel-on-travis/

Another is a PHP script that I cobbled together for a client: https://github.com/livinglab/openlab/blob/master/developer/lint-php.php. This approach is nice because we can easily define a blacklist.

Attachments (3)

7926.diff (2.6 KB) - added by boonebgorges 6 years ago.
7926.grunt.diff (2.1 KB) - added by boonebgorges 6 years ago.
7926.grunt.2.diff (128.8 KB) - added by netweb 6 years ago.

Download all attachments as: .zip

Change History (10)

@boonebgorges
6 years ago

#1 @boonebgorges
6 years ago

  • Keywords has-patch added; needs-patch removed
  • Milestone changed from Awaiting Contributions to 4.0

7926.diff is a first pass at a linting script. It doesn't currently have any exclusions, but the infrastructure is there for it. It runs across all PHP files, including tests.

Note that this kind of fix doesn't actually catch the kind of incompatibility discussed in #7925. PHP's linter doesn't execute files to test for failures, it only scans for improper syntax. Something like #7925 could perhaps be caught with a PHPUnit test, or with static code analysis.

That being said, I think this kind of linting still have value. Any thoughts?

#2 follow-up: @boonebgorges
6 years ago

7926.grunt.diff is maybe smarter - it uses a grunt task for linting, so everything's centralized. This approach could use the eyes of @netweb, as it does things to my local npm-shrinkwrap that I don't understand.

@netweb
6 years ago

#3 in reply to: ↑ 2 @netweb
6 years ago

  • Keywords commit added; 2nd-opinion removed

Replying to boonebgorges:

7926.grunt.diff is maybe smarter - it uses a grunt task for linting, so everything's centralized.

Works for me +1

This approach could use the eyes of @netweb, as it does things to my local npm-shrinkwrap that I don't understand.

I've added a .npmrc file to 7926.grunt.2.diff that will now use ~ (tilde) as the default semver prefix instead of the default ^ (caret) and also updated the npm-shrinkwrap.json file with all the required changes in this ticket. WordPress itself has also made this switch, or if it hasn't its just because it hasn't been committed to trunk.

Not a blocker for this ticket but I'm wondering if the grunt phplint ask should also operate on Travis CI accross multiple PHP versions? 💥

#4 @boonebgorges
6 years ago

In 12193:

Add PHP linting to travis:phpunit and commit Grunt tasks.

This enforces linting pre-commit, and as part of the Travis PHP matrix.

As part of this changeset, we are switching to the use of ~ as the
default semver prefix in our package.json.

Props netweb.
See #7926.

#5 @boonebgorges
6 years ago

  • Milestone 4.0 deleted
  • Resolution set to invalid
  • Status changed from new to closed

Thanks, @netweb !

Not a blocker for this ticket but I'm wondering if the grunt phplint ask should also operate on Travis CI accross multiple PHP versions? 💥

Ah yes, when I added it to grunt commit, I forgot it'd need to be handled separately for Travis. As part of travis:phpunit, it ought to be run across the whole matrix.

Let's put this in and see what happens.

#6 @boonebgorges
6 years ago

  • Resolution changed from invalid to fixed

The Travis build seems to have run properly - phplint was run for each job, meaning it gets run across the entire PHP version matrix - so I think we are good.

#7 @boonebgorges
6 years ago

  • Milestone set to 4.0
Note: See TracTickets for help on using tickets.