PHPCS is run even when it cannot check any files
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3514486. --> Reported by: [jonathan1055](https://www.drupal.org/user/92645) Related to !368 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>The PHPCS job is added to the pipeline and runs even when there are no files for it to check.</p> <p>Here is an example where there a no .php files or any other file extensions that PHPCS can check. Running with <code>_PHPCS_EXTRA: -v</code> shows <a href="https://git.drupalcode.org/project/gitlab_templates_downstream/-/jobs/4714746#L200">0 files checked</a>. </p> <p>Here is <a href="https://git.drupalcode.org/issue/coding_standards-3527545/-/jobs/5473059#L203">another example</a>, in the new Coding Standards project repo, which has no php files. See comment 4 on <span class="drupalorg-gitlab-issue-link project-issue-status-info project-issue-status-7"><a href="https://www.drupal.org/project/coding_standards/issues/3527481" title="Status: Closed (fixed)">#3527481: Run cspell and other linting/validation jobs</a></span>. It is odd to have the job running when it cannot do anything.</p> <p>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:</p> <p>1. Gitlab templates assets/phpcs.xml has 8 extensions <code>php,inc,module,install,info,test,profile,theme</code><br> It does not have <strong>engine</strong> or <strong>yml</strong></p> <p>2. The variable <code>$DRUPAL_PHP_FILE_TYPES</code> used in rule .php-files-exist is defined with 7 extensions <code>php,module,install,inc,profile,theme,engine</code><br> It does not have <strong>test</strong>, <strong>info</strong> or <strong>yml</strong></p> <p>3. Core 11.1 phpcs.xml.dist has 9 extensions: <code>engine,inc,install,module,php,profile,test,theme,yml</code><br> It does not have <strong>info</strong></p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <ul> <li>Add the rule <code>.php-files-exist</code> to the phpcs job defintions</li> <li>Syncronize the list of files used in the rule with the extensions specified in the default <code>assets/phpcs.xml</code> file</li> <li>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.</li> </ul>
issue