Keep all sniffs in phpcs.xml.dist in sync with the list got from the locked version of coder

Created on 12 May 2020, almost 5 years ago
Updated 30 January 2023, about 2 years ago

Problem/Motivation

As discussed in #3134731: Update coder to 8.3.9 β†’ with @longwave and @jonathan1055, we decided to get phpcs.xml.dist sorted first in #3135933: Sort sniffs/rules in phpcs.xml.dist and write test to keep them sorted β†’ . and furthermore in this issue, to write a test to ensure all sniffs (commented out or not) phpcs.xml.dist are in sync with the list got from the locked version of coder.

Proposed resolution

@longwave:

Alternatively: is it possible to say something like

<rule ref="Drupal">
<exclude name="..." />
<exclude name="..." />
<exclude name="..." />
<exclude name="..." />
</rule>

so we only explicitly exclude sniffs we know about? Then when we upgrade Coder and get new sniffs, they automatically apply, and we have to either fix or exclude them?

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Needs work

Version

10.1 ✨

Component
OtherΒ  β†’

Last updated about 21 hours ago

Created by

πŸ‡¨πŸ‡³China jungle Chongqing, China

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • πŸ‡¦πŸ‡ΉAustria klausi πŸ‡¦πŸ‡Ή Vienna

    I found out by accident that core has implemented some sniffs in phpcs.xml.dist that are missing in Coder. Opened πŸ“Œ Adopt PHPCS config from Drupal core that is missing in Coder Active , Coder 8.3.27 is now in sync again.

    The proposed solution in the issue summary here is good, we should do it exactly like that.

  • πŸ‡³πŸ‡ΏNew Zealand quietone

    And core has a sniff that was removed from Coder, πŸ“Œ Remove Drupal.Commenting.FunctionComment.TypeHintMissing from phpcs.xml.dist Active .

  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    Recreated #7. I added with the entire Drupal and DrupalPractice sets except the rules we already exclude, removed any duplicates that are already in those sets, and added further exclusions for rules that we don't meet yet.

    Given that we now pin to a specific version of Coder and also that our CI jobs are now much better than before, I think this is a better format for the file - it's easier to see which standards we don't adhere to yet, and we will never be surprised as we are in control of upgrading Coder.

  • Pipeline finished with Success
    18 days ago
    Total: 317s
    #414060
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    Yes, lets do this.

  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    Did some more cleanup on this; I've rearranged the file and many comments to make it easier to follow. It's easier to review the new version of the file instead of trying to read the diff here.

    I discovered that Coder disables SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing but we want it enabled for tests, so we explicitly re-enable it here. I've done a number of further checks by breaking coding standards in files and ensuring that things are still caught as expected.

    I think the <file> section is wrong as the .sh files don't seem to get checked, but that can wait for a followup.

  • πŸ‡§πŸ‡ͺBelgium borisson_ Mechelen, πŸ‡§πŸ‡ͺ

    I don't have any remarks. I think this looks good. It does make it so that coder has to be a bit more careful when adding new rules I guess?

  • πŸ‡³πŸ‡ΏNew Zealand quietone
  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    Apologies for the scope creep but SortTest was failing because it required exclude-pattern to be sorted at the top level; it's nicer to be able to group these with comments so I removed that test, but I also added additional tests to ensure include-pattern and exclude-pattern inside rules are correctly sorted, and fixed all cases where this was not met.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Appears to need a rebase

    @longwave what's a good way for testing this one?

    If you are another contributor eager to jump in, please allow the previous poster at least 48 hours to respond to feedback first, so they have the opportunity to finish what they started!

Production build 0.71.5 2024