- Issue created by @tr
- πΊπΈUnited States cmlara
This sniff is being applied to contributed modules when phpcs is run, but as far as I can tell it's not being used in core. I don't know if this is intentional or not.
I'll note that DrupalPractice sniffs are 'common practices' however to my knowledge the majority of them are not actually codified by the Drupal Coding Standard. There are some good sniffs in there however they may not fit for every situation.
The default for gitlab_templates only uses the Drupal profile not the DrupalPractice profile.
If a maintainer goes through the Project Applications queue to receive the 'git vetted' role (permission to opt projects into security coverage) role the DrupalPractice ruleset is often applied and some 'contributors' believe the DrupalPractice is a required standard.
So the problem is the differing standards between what is allowed in core and what is allowed in contrib.
To my knowledge Core has never fully complied with the Drupal Coding Standards. They use it as a guideline for new code however it is not fully enforced by testing as their code is not up to full coding standards and some standards are deemed 'too disruptive' to implement.
I don't see that this sniff is being explicitly excluded from core either.
Core selectively enables sniffs, they do not use the Drupal or DrupalPractice per-configured profiles that contrib often uses.
The current sniffs used by core are located in:
https://git.drupalcode.org/project/drupal/-/blob/11.x/core/phpcs.xml.dis...Can someone point me to documentation or explain to me how this situation happens and how to correct it in core?
https://www.drupal.org/docs/develop/issues/issue-procedures-and-etiquett... β contains the procedure for proposing a new coding standard be used in core.
https://www.drupal.org/project/coding_standards β discusses in step 9 of the templates procedure discusses that after the coding standards committee adopts a new standard an issue be created in core to add the rule to phpcs.xml.dist and to cleanup any code that may not comply. Obviously code that is not in the formal coding standards would never trigger this step (also 2022 was back when the Coding Standards committee was defunct).
- π³πΏNew Zealand quietone
It is true that Drupal core is not fully compliant with the Drupal Coding standards, and that the set of sniff automatically enforced by core is different than contrib.
Core continues to work to enforce all the Drupal Standards but not Drupal Practice. That work has been happening for many years and continues. It is done incrementally, that is, as core becomes compliant with a standard, the relevant sniff is enabled. For example, since Jan 1, 2025 there have been 35 changes core/phpcs.xml.dist, adding enforcement of a standard on all, or part, of the code base.
To find out more about how coding standards work happens, there is the Coding Standard project β and there is a #coding-standards in Drupal Slack.
The related issue in core is π [Meta] Fix coding standards in core Active .