Problem/Motivation

Currently, there is no tool that will check the various cspell lines in core to see if they are still needed. No does cspell offer such a thing. Although there is an issue, https://github.com/streetsidesoftware/cspell/issues/4150.

Most of the lines in core are cspell:ignore with a few cspell:disable-next-line. The latter are near code being changed so is more likely to be kept up to date. However, the ignore lines are at the top of the file and are easy to get out of sync.

Steps to reproduce

Proposed resolution

Add a check in commit-code-check.sh to report if any of the words in a cspell:ignore line in any of the modified files can be removed.

Remaining tasks

Review
Manual testing

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#2 3390959-2.patch1.52 KBquietone

Issue fork drupal-3390959

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

quietone created an issue. See original summary.

quietone’s picture

Status: Active » Needs review
StatusFileSize
new1.52 KB

I applied the patch and ran the script for two cases. The following shows the relevant part of the output.

1) Add a word that is not used to an ignore line.

$ ddev commit-code-check --cached
/var/www/html/core/modules/block/tests/src/Unit/Plugin/migrate/process/BlockVisibilityTest.php: xyzzy

CSpell: Ignored words can be removed
1/1 ./modules/block/tests/src/Unit/Plugin/migrate/process/BlockVisibilityTest.php 323.07ms
2/2 ./scripts/dev/commit-code-check.sh 203.57ms
CSpell: Files checked: 2, Issues found: 0 in 0 files

CSpell: failed

1) Add a comment to a file that has an ignore line.

$ ddev commit-code-check --cached

CSpell: No ignored words found
1/1 ./modules/block_content/tests/src/Kernel/Plugin/migrate/source/d6/BoxTranslationTest.php 334.55ms
2/2 ./scripts/dev/commit-code-check.sh 14.46ms
CSpell: Files checked: 2, Issues found: 0 in 0 files

CSpell: passed

No need to run tests but setting to NR.

quietone’s picture

Title: Add check words in 'cspell:ignore' that can be removed » Test for words in 'cspell:ignore' that can be removed
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Verified this was working.

Applied patch #2

In action.module I added // cspell:ignore addedline which is a word in the dictionary.txt

Running commit-code-check.sh I got

Stephens-MBP:web $:./core/scripts/dev/commit-code-check.sh --cached
/Users/smustgrave/Sites/Drupal-Demos/drupal-11.x/web/core/modules/action/action.module: addedline

CSpell: Ignored words can be removed
1/1 ./modules/action/action.module 249.26ms
2/2 ./scripts/dev/commit-code-check.sh 9.18ms
CSpell: Files checked: 2, Issues found: 0 in 0 files

Removing the line from action.module and running again was all green.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

We need to update the gitlab-ci pipeline to do this otherwise only committers might run this check.

quietone’s picture

Status: Needs work » Needs review

I agree that this needs to be run in gitlab. However, I think that part is better that it is done as part of or after this issue, #3386841: Reconcile gitlab lint jobs and commit-code-check.sh. That issue is proposing breaking up commit-code-check into several scripts that can be run in both environments. So, this would just be incorporating into one of those new scripts instead of direct additions to the pipeline.

needs-review-queue-bot’s picture

Status: Needs review » Needs work

The Needs Review Queue Bot tested this issue.

While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)

quietone’s picture

Status: Needs work » Needs review
Issue tags: +no-needs-review-bot

Let's get a response to #6 before changing to an MR or other work on the code.

smustgrave’s picture

Status: Needs review » Needs work

Brought this up in #needs-review-queue-initiative channel and @alexpott mentioned this should be added to pipeline.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.