PHPCS error in contributed module caused by core recipe README.txt

Created on 22 December 2024, 2 days ago

In GitLabCI testing now that Drupal 11.1 is the current version, I have started to see this PHPCS failure:

FILE: ...builds/project/ip2country/web/modules/custom/ip2country/recipes/README.txt
--------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
--------------------------------------------------------------------------------
 9 | ERROR | [x] Expected 1 newline at end of file; 2 found
   |       |     (Drupal.Files.EndFileNewline.TooMany)
--------------------------------------------------------------------------------

See https://git.drupalcode.org/project/ip2country/-/jobs/3792045
The problem showed up in my weekly scheduled testing as of 21 Dec - this did not happen in the previous test on 14 Dec when the current core version was 11.0.

Note that the recipes/README.txt is not present in my project's repository, so I assume this is something that is added during GitLabCI testing. Regardless, it's not part of my project so I can't fix it in my project.

I think that what is happening is that core/assets/scaffold/files/recipes.README.txt is being copied into my project for testing purposes (why?).

This core README.txt does have the above problem - there's a blank line at the end when there shouldn't be. This was committed in πŸ“Œ Add support for recipes to drupal/recommended-project Needs review , so perhaps someone can look to see how that was put into core with a PHPCS violation?

Here's a patch to fix that file, which hopefully trickles down to fix the issue in my project's testing.

πŸ› Bug report
Status

Active

Version

11.1 πŸ”₯

Component

recipe system

Created by

πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

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

Merge Requests

Comments & Activities

  • Issue created by @tr
  • Pipeline finished with Failed
    2 days ago
    Total: 636s
    #376524
  • πŸ‡³πŸ‡ΏNew Zealand quietone

    The PHPCS checks in core do not check .txt files. It runs on these extensions, <arg name="extensions" value="engine,inc,install,module,php,profile,test,theme,yml"/>. Where the module ipcountry is using a custom phpcs.xml that is checking .txt files.

    I suggest that the custom phpcs.xml be modified to only check files in that module.

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    Where the module ipcountry is using a custom phpcs.xml that is checking .txt files.

    Ah, thank you for noticing that.

    But still, why is recipe.README.txt being moved into my modules codebase on GitLabCI if I don't have any recipes in the module and I am not testing recipes?

    I think it still makes sense to patch recipe.README.txt so that it complies with coding standards, even if core doesn't about checking .txt files.

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

    I don't know why phpcs for the module is running phpcs on core files, that sounds like a question for the gitlab templates project.

    Drupal does not have coding standards for .txt files, so there isn't currently anything to comply with. The standard that does exist about the end of a file is for PHP files. The closest issue I know about is the Coding Standards one for markdown, #2952616: Adopt CommonMark spec for Markdown files β†’ .

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    I don't know why phpcs for the module is running phpcs on core files, that sounds like a question for the gitlab templates project.

    No, you misread. FILE: ...builds/project/ip2country/web/modules/custom/ip2country/recipes/README.txt is a file inside the ip2country project folder. Presumably it was copied there by the GitLabCI job, because it is not present in the module's codebase.

  • πŸ‡¨πŸ‡¦Canada Charlie ChX Negyesi 🍁Canada

    I believe there are two independent problems here:

    1. Trivial core fix to delete the spurious newline

    2. Figure it out whether the core composer.json or https://git.drupalcode.org/project/gitlab_templates/-/blob/main/scripts/... causes this

  • πŸ‡ΊπŸ‡ΈUnited States tr Cascadia

    Yes, two independent issues, as you said. The MR addresses #1, but I don't know where to start with #2 because what's happening behind the scenes during GitLabCI deployment doesn't show up in the logs/artifacts.

    I can narrow it down a bit because @quietone noted that my phpcs.xml.dist enables phpcs checking of txt files, while the core default does not check txt files.

    Upon further examination, I see this exact same phpcs error on [modulename]/recipe/README.txt in every project I own that does phpcs checks on txt files. If you don't enable phpcs checks on txt files, you will never notice that recipe.README.txt file is getting copied into every project during GitLabCI testing.

    I had tagged this issue with "Recipe initiative" because I though someone involved with the recipe project might recognize why this file is being copied into a contrib module folder.

Production build 0.71.5 2024