Active
Project:
Drupal core
Version:
main
Component:
other
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
29 Sep 2017 at 15:53 UTC
Updated:
20 Oct 2025 at 06:19 UTC
Jump to comment: Most recent
Follow-up to #2571965: [meta] Fix PHP coding standards in core, stage 1
Step by step we are going to add new rules to phpcs.xml.dist
But the approach to exclude sniffs not related to Drupal CS or postponed is different
exclude wrapperrule with severityWe have two groups of sniffs that we need to exclude:
Rewrite phpcs.xml.dist using following approach:
<exclude> wrapper and commit it for ever :)<severity>0</severity> directive. This directive is more related to goal that we need: "Hide errors of postponed sniffs"
Comments
Comment #2
andriyun commentedComment #3
andypostYep, next step is polishing - removing of warnings
Comment #4
andriyun commentedComment #5
mile23There are two goals for this process:
So if there's an exclude that doesn't appear in ruleset.xml, then the solution is to fix the CS error in core, so we can remove the exclusion.
In the example given above at http://cgit.drupalcode.org/drupal/tree/core/phpcs.xml.dist#n54, there are a bunch of exclusions for
Drupal.Commenting.FunctionComment. These are being addressed in #2572645: [Meta] Fix 'Drupal.Commenting.FunctionComment' coding standard so eventually they'll go away.Comment #6
ivan berezhnov commentedComment #16
jonathan1055 commentedThis is a good idea. Having two sections in phpcs.xml.dist, the first being described as "we are not ever going to follow these sniffs" and have them excluded. The second section could be described as "Yes we like these, and want to follow them, and are slowly working through fixing core". These would have severity 0 whilst the work is being done, and then that would be removed when core follows the standard.
Overall this will mean that phpcs.xml.dist shrinks as we get more are more sniffs passing in Core. Currently, the file expands each time a new sniff passes.
Historically, it has been done this way (only adding a sniff when it passes in core) so that if Coder adds a brand-new sniff we don't have Core immediately failing the tests. However, I think this should not be a problem. The version of Coder applicable to Core is generally only upgraded when moving to a new minor release, i.e. 9.4 to 9.5. If the first runs of core at a new minor release fail for new Coder sniffs then that is precisely and exactly a good time to add these new sniffs to the second section, with severity 0. This can be done very quickly and easily so it would not mean that Core tests fail for very long.
Comment #19
quietone commented