PHPCS is run even when it cannot check any files
Problem/Motivation
The PHPCS job is added to the pipeline and runs even when there are no files for it to check.
Here is an example where there a no .php files or any other file extensions that PHPCS can check. Running with _PHPCS_EXTRA: -v shows 0 files checked.
Here is another example, in the new Coding Standards project repo, which has no php files. See comment 4 on #3527481: Run cspell and other linting/validation jobs. It is odd to have the job running when it cannot do anything.
In total there are 10 different file extensions that we are concerned with. The lists are defined differently in various places so here are the three we are concerned with:
1. Gitlab templates assets/phpcs.xml has 8 extensions php,inc,module,install,info,test,profile,theme
It does not have engine or yml
2. The variable $DRUPAL_PHP_FILE_TYPES used in rule .php-files-exist is defined with 7 extensions php,module,install,inc,profile,theme,engine
It does not have test, info or yml
3. Core 11.1 phpcs.xml.dist has 9 extensions: engine,inc,install,module,php,profile,test,theme,yml
It does not have info
Proposed resolution
- Add the rule
.php-files-existto the phpcs job defintions - Syncronize the list of files used in the rule with the extensions specified in the default
assets/phpcs.xmlfile - The only difference is that .yml files are not included in the rule to trigger the job, because if a project has no other php file types then the phpcs job should not run. But yml files are checked by phpcs if they exist, so yml is included in the phpcs.xml extensions list.