Fix Drupal.Commenting.FunctionComment.Missing in module tests

Created on 4 April 2025, 5 months ago

Problem/Motivation

Working to enable the sniff Drupal.Commenting.FunctionComment.Missing.

Steps to reproduce

Proposed resolution

Fix this sniff for module tests

Remaining tasks

Create an MR
Enable the sniff in phpcs.xml.dist to include module tests
Fix reported errors
Review

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

11.0 🔥

Component

other

Created by

🇳🇿New Zealand quietone

Live updates comments and jobs are added and updated live.
  • Coding standards

    It involves compliance with, or the content of coding standards. Requires broad community agreement.

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @quietone
  • Merge request !11732enable for tests in modules → (Open) created by quietone
  • Pipeline finished with Failed
    5 months ago
    Total: 103s
    #465415
  • 🇳🇿New Zealand quietone

    Linting passed, so setting for review.

  • 🇮🇳India annmarysruthy

    Reviewed the MR. Changes look good to me. Also ignoring the sniff in files using testN() seems to be fine.

  • The Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

  • Status changed to Needs review 2 months ago
  • 🇳🇿New Zealand quietone

    Time to get some reviews here.

  • Pipeline finished with Failed
    2 months ago
    Total: 525s
    #526184
  • 🇺🇸United States smustgrave

    Re-ran test failures and they were all random.

    Was previously RTBC restoring status

  • 🇬🇧United Kingdom longwave UK

    Found a couple of nits.

  • Pipeline finished with Failed
    about 1 month ago
    #548530
  • Pipeline finished with Success
    about 1 month ago
    Total: 1146s
    #548543
  • 🇳🇿New Zealand quietone

    @longwave, thanks for the review. I made the corrections and checked if any other changes were needed due to the recent update of Coder.

  • 🇺🇸United States smustgrave

    Feedback appears to be addressed

  • 🇺🇸United States xjm

    Midway through my review. The hook order tests need so much work that IMO we might want to pull them out into their own issue, especially since this is one of those test fixture sets where understanding exactly what is under test is important.

  • 🇺🇸United States xjm

    OK, done reviewing now. Phew, this one is massive! Given the 290 total LOC diffstat of all new docs that furthermore requires you to read not only the context lines of the method but also entirely separate code of the tests these fixtures are for, I think the scope of this is too big. There are two particularly problematic tests that I think should be moved to their own separate issues. Thanks!

  • 🇺🇸United States xjm

    It's not module tests; it's test modules.

  • Pipeline finished with Canceled
    28 days ago
    Total: 719s
    #557254
  • Pipeline finished with Failed
    28 days ago
    Total: 616s
    #557261
  • Pipeline finished with Failed
    28 days ago
    Total: 675s
    #557277
  • Pipeline finished with Success
    28 days ago
    Total: 816s
    #557340
  • Pipeline finished with Failed
    28 days ago
    Total: 700s
    #557454
  • 🇳🇿New Zealand quietone

    I'm going to move the changes for HookOrder to another issue. Assigning to myself for that and to review other local changes before pushing.

  • Pipeline finished with Success
    12 days ago
    Total: 583s
    #569943
  • Pipeline finished with Success
    12 days ago
    Total: 649s
    #569966
  • 🇳🇿New Zealand quietone

    Removed the hook related ignores, except one for what is an unused function, \template_preprocess_test.

  • Pipeline finished with Failed
    12 days ago
    Total: 603s
    #570032
  • 🇺🇸United States nicxvan

    How are these for comments on each?

    diff --git a/core/modules/system/tests/modules/module_test_procedural_preprocess/module_test_procedural_preprocess.module b/core/modules/system/tests/modules/module_test_procedural_preprocess/module_test_procedural_preprocess.module
    index 1e7665b412d..99f405dbf76 100644
    --- a/core/modules/system/tests/modules/module_test_procedural_preprocess/module_test_procedural_preprocess.module
    +++ b/core/modules/system/tests/modules/module_test_procedural_preprocess/module_test_procedural_preprocess.module
    @@ -7,14 +7,25 @@
     
     declare(strict_types=1);
     
    +/**
    + * Confirms that template_preprocess_HOOK functions are gathered and executed
    + * when there is no initial preprocess key set on hook_theme.
    + */
     function template_preprocess_test($arg): mixed {
       return $arg;
     }
     
    +/**
    + * Confirms that procedural hook_preprocess() hooks are gathered and executed.
    + */
     function module_test_procedural_preprocess_preprocess($arg): mixed {
       return $arg;
     }
     
    +/**
    + * Confirms that procedural hook_preprocess_HOOK() hooks are gathered and
    + * executed.
    + */
     function module_test_procedural_preprocess_preprocess_test($arg): mixed {
       return $arg;
     }
    

    I'll create a follow up to ensure the template preprocess coverage is as expected.

  • Pipeline finished with Success
    11 days ago
    Total: 647s
    #570609
  • 🇳🇿New Zealand quietone

    I commented an hour ago but forgot to save. Here is that comment.

    @nicxvan, thanks for prompt response to our Slack conversation about this. I updated your suggestions in the MR. In particular, wanting to add more detail so that the last two functions do not have identical comments. This was pointed out by xjm and is why I have moved adding comments to the HookOrder related test modules to a new issue.

    Linting passed, back to Needs review.

  • 🇺🇸United States nicxvan

    Please link me to the hook order documentation issue when you create it. They are pretty difficult to hold all in your head so a summary of expected orders would be great, just not sure where.

    I did manually map them out and confirm them all as part of the hook ordering issue they were added in, but I couldn't figure out where to document it.

    The ones I wrote I kept much more simple with only a couple hooks per test, but this was more comprehensive and realistic test coverage.

  • 🇳🇿New Zealand quietone

    @nicxvan, the diff in #13 has the same comment for two of the functions and @xjm wants a specific message for each function. One that explains what it is testing. I can appreciate that, there is nothing in the file to explain why two very similar functions are needed.

  • 🇺🇸United States nicxvan

    Yep, I resolved my threads. They are different hooks but I think it's clear from the context what they are.

    The test called them prefix because Registry does. But I don't think I've seen the module name called a prefix other than that. Same for HOOK being called a suffix.

    I don't think that's worth holding this up, but there is one other follow up needed for the router test.

    Once those are linked and is green this is rtbc as far as I am concerned.

  • Pipeline finished with Success
    11 days ago
    Total: 7477s
    #570642
  • Pipeline finished with Failed
    11 days ago
    Total: 666s
    #570729
Production build 0.71.5 2024