CSpell should never be run against patch files

Created on 9 September 2024, 3 months ago
Updated 20 September 2024, 3 months ago

Problem/Motivation

Patch files, by design, contain parts of source from other files. This can cause spelling error to be reported in the patch file if the original file is ignored, either via cspell:disable, being included in _CSPELL_IGNORE_PATHS or it is one of the standard ignored files.

Proposed resolution

Do not run CSpell on any patch file.
Add something **/*.patch to the list of files that should never be checked.

Remaining tasks

📌 Task
Status

RTBC

Component

gitlab-ci

Created by

🇬🇧United Kingdom jonathan1055

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

Merge Requests

Comments & Activities

  • Issue created by @jonathan1055
  • Merge request !256#3473051 Do not run CSpell on patch files → (Merged) created by jonathan1055
  • Pipeline finished with Failed
    3 months ago
    Total: 110s
    #278240
  • Status changed to Needs review 3 months ago
  • 🇬🇧United Kingdom jonathan1055

    First draft, ready for review. I have tested this locally and it does what is required.

    To do this I used ./scripts/run-local-checks.sh which also required the inclusion of prepare-cspell.php in that script. Initially I had the modified .cspell.json but the changes did not seem to be respected. Then I realised that at the top of run-local-checks all the files in /assets/internal/ are copied to the project top folder, thus over-writing the modified .cspell.json. Running prepare-cspell.php inside run-local-checks.sh works fine and it means we can easily test any changes to the spelling process.

  • 🇬🇧United Kingdom jonathan1055

    Test without this MR - cspell reports "commerceguys" in a patch on composer.json
    https://git.drupalcode.org/project/scheduler/-/jobs/2698245

    Test with this MR - cspell passes. (The display of .cspell.json is for info, to show the *.patch. This is in the Scheduler after_script, not the gitlab job)
    https://git.drupalcode.org/project/scheduler/-/jobs/2698527

  • Status changed to Needs work 3 months ago
  • 🇪🇸Spain fjgarlin

    Why not just adding the *.patch to the $ignore_files array? It'd be a one-line change and we introduced that variable for this purpose?

  • 🇬🇧United Kingdom jonathan1055

    I thought about that initially, but the difference is that patch files should never be checked. You may want _CSPELL_IGNORE_STANDARD_FILES: 0 for other reasons, but you would still not want patch files checked. Actually, the .svg files could be moved into the "never" list, as they contain plenty of words which will always fail. Likewise the '.*ignore' entry can be moved into the new array.

  • Pipeline finished with Failed
    3 months ago
    Total: 51s
    #279957
  • Pipeline finished with Failed
    3 months ago
    Total: 53s
    #279961
  • Pipeline finished with Success
    3 months ago
    Total: 52s
    #286210
  • Pipeline finished with Success
    3 months ago
    Total: 51s
    #286279
  • 🇬🇧United Kingdom jonathan1055

    This issue can also be used to make another improvement that I've been meaning to suggest. I noted that the projects own .gitlab-ci.yml file is not being checked for spelling and I think it should do. I've added a spelling error and you can see that the job still passes. The log has

    CSpell: Files checked: 49, Issues found: 0 in 0 files.
    

    The next commit will show the spelling error and the job should fail.

  • Pipeline finished with Failed
    3 months ago
    Total: 53s
    #286285
  • 🇬🇧United Kingdom jonathan1055

    As intended the Check Code job detected the spelling error of "checkkk"

    gitlab-ci.yml:4:52      - Unknown word (checkkk)    -- demonstrate spelling checkkk
    	 Suggestions: [checkmk, check, checks, checky, check's]
    .gitlab-ci.yml:112:44    - Unknown word (shellcheck) -- apt-get install -y shellcheck
    	 Suggestions: [spellcheck, spellchecks, shellcheckrc, shellack, shellback]
    .gitlab-ci.yml:139:7     - Unknown word (shellcheck) -- shellcheck --version
    	 Suggestions: [spellcheck, spellchecks, shellcheckrc, shellack, shellback]
    .gitlab-ci.yml:140:7     - Unknown word (shellcheck) -- shellcheck scripts/*.sh || EXIT
    	 Suggestions: [spellcheck, spellchecks, shellcheckrc, shellack, shellback]
    CSpell: Files checked: 57, Issues found: 4 in 1 file.
    

    The word 'shellcheck' is not reported locally when using ./scripts/run-local-checks.sh and I think this is because we are not using prepare-cspell.php in "Check Code". That should be done, because it adds more of the standard dictionaries than we have specified in the project's .cspell.json file.

  • Pipeline finished with Failed
    3 months ago
    #286294
  • Pipeline finished with Success
    3 months ago
    Total: 51s
    #286297
  • 🇬🇧United Kingdom jonathan1055

    As expected, this has removed the unknown word "shellcheck" and we just get the one intended error

    .gitlab-ci.yml:4:52      - Unknown word (checkkk)    -- demonstrate spelling checkkk
    	 Suggestions: [checkmk, check, checks, checky, check's]
    CSpell: Files checked: 49, Issues found: 1 in 1 file.

    https://git.drupalcode.org/issue/gitlab_templates-3473051/-/jobs/2785755

    Ready for review, but no hurry as other things are more urgent.

  • Status changed to Needs review 3 months ago
  • 🇪🇸Spain fjgarlin

    Great progress. Thanks!

  • Status changed to Needs work 3 months ago
  • 🇪🇸Spain fjgarlin

    Really minor feedback which may or may not need action.

  • Pipeline finished with Success
    3 months ago
    Total: 53s
    #287085
  • Pipeline finished with Success
    3 months ago
    Total: 48s
    #287096
  • Status changed to Needs review 3 months ago
  • 🇬🇧United Kingdom jonathan1055

    Applied the suggestions, thanks. Needs review.
    I thought it would be simpler to ignore the .env.example file here, as I know it fails spelling, but to fix it would cause an unnecessary conflict with MR242 (which is much more important that this issue of spelling)

  • Pipeline finished with Success
    3 months ago
    #287193
  • Pipeline finished with Success
    3 months ago
    Total: 50s
    #287200
  • Pipeline finished with Success
    3 months ago
    Total: 53s
    #287206
  • 🇬🇧United Kingdom jonathan1055

    Fewer files are being spell-checked here compared to when I run it locally. Then I realsied that we need to set export _CSPELL_IGNORE_STANDARD_FILES=0 here.

    First test as-is, showing what we are checking
    CSpell: Files checked: 49, Issues found: 0 in 0 files.
    https://git.drupalcode.org/issue/gitlab_templates-3473051/-/jobs/2795873

    Now with not ignoring the extra files
    CSpell: Files checked: 57, Issues found: 0 in 0 files.
    https://git.drupalcode.org/issue/gitlab_templates-3473051/-/jobs/2795946

    This is important, because among the 8 extra files being checked now are 3 which we really do want to check - CHANGELOG.md, docs/jobs/composer.md and docs/jobs/phpstan.md (the other 5 are .cspell.json, .gitignore, composer.json, package.json and scripts/.gitignore)

  • Status changed to RTBC 3 months ago
  • 🇪🇸Spain fjgarlin

    Well spotted. I reviewed the code and it looks good. RTBC.
    Thanks!

  • Pipeline finished with Success
    3 months ago
    Total: 51s
    #290313
  • Pipeline finished with Success
    3 months ago
    Total: 53s
    #290348
  • Pipeline finished with Skipped
    3 months ago
    #290364
  • 🇪🇸Spain fjgarlin

    Merged! Thanks.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024