[wp-trac] [WordPress Trac] #54064: Add phpcs run command to Docker

WordPress Trac noreply at wordpress.org
Thu Sep 2 20:31:01 UTC 2021


#54064: Add phpcs run command to Docker
------------------------------+------------------------------
 Reporter:  pbearne           |       Owner:  (none)
     Type:  defect (bug)      |      Status:  new
 Priority:  normal            |   Milestone:  Awaiting Review
Component:  Build/Test Tools  |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch         |     Focuses:
------------------------------+------------------------------

Comment (by jrf):

 @pbearne While I don't think it's a bad idea to add these commands, this
 doesn't directly address the problem you highlighted: that the GH actions
 output of the PHPCS run indecipherable (because it is formatted for
 display in a PR via the cs2pr tool).

 To address that second point, I'd like to suggest also fixing the commands
 used in the GH actions workflows as per the [https://github.com/staabm
 /annotate-pull-request-from-checkstyle#using-php_codesniffer second code
 sample for PHPCS in the cs2pr readme].

 For local use, running the commands as proposed to be added to the Docker
 scripts is highly inefficient (slow) as PHPCS will scan the whole project.

 For most users, it may be a good idea to educate them about PHPCS better
 (though I don't know exactly where to do this).

 If you want to run these commands in Docker, that means you will have
 already run `composer install or `composer update` locally.

 In that case, you don't need to be in the Docker container to run a local
 PHPCS check as you can run the existing Composer scripts: `composer
 compat`, `composer lint`, `composer lint:errors` or `composer format`.

 Better yet, call `vendor/bin/phpcs` directly using `--filter=GitStaged` (=
 staged files) or `--filter=GitModified` (= unstaged files) to get PHPCS to
 scan just and only the files which have been changed, but not committed
 yet.


 As a side-note, it would probably be a good idea to use the same script
 names and scripts in the Docker config as are used in the Composer config
 for consistency and probably even better for Docker to call the Composer
 scripts under the hood as otherwise the chances are high that at some
 point one of the scripts will be adjusted in one, but not the other file
 and they will diverge, making the outcome even more unpredictable across
 workflows.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54064#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list