Problem/Motivation

We have added a spellcheck to Drupal core. The Postgres schema driver contains a number of SQL column and function names that are not English words and do not appear elsewhere in core.

Proposed resolution

Ignore the words when spellchecking and remove them from the dictionary.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

longwave created an issue. See original summary.

longwave’s picture

longwave’s picture

Maybe an alternative option here is to use cSpell:ignore which should ignore these words for the file in question only, if my reading of the docs is correct.

jungle’s picture

Another option is to ignore the whole file by adding the file path to "ignorePaths" of .cspell.json, The patch attached adopted this way which @alexpott did before.

longwave’s picture

For me #4 is the wrong approach here. Ignoring entire files is OK when we don't have control over them, or want to ignore a large set of things such as the migration tests, but really we should spellcheck this file except for a small number of words.

jungle’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
7.46 KB
1.03 KB

Then, let's go the way #2 did. run "spellcheck:make-drupal-dict" updated the dictionary, new words from recent commits probably and setting this to RTBC.

jungle’s picture

Patch re-rolled.

longwave’s picture

longwave’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
2.01 KB

This seems a bit cleaner to me than adding disable/enable everywhere; we list upfront in each file the words that will be ignored.

This might work better for the FilterID case as well.

jungle’s picture

As a reference: The doc of cSpell:ignore: https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell...

Using cSpell:ignore is cleaner than using cSpell:enable/disable and its variations.

But it's harder to get rid of words if code were changed, and the word(s) should be removed from the ignored ones.

For maintainability, -1

jungle’s picture

Or adding above to the line closing to where words show up the first time

longwave’s picture

Status: Needs review » Needs work

> Or adding above to the line closing to where words show up the first time

That's a better idea for maintainability, I think? Adding all these cSpell comment lines everywhere does feel a bit ugly but that seems a bit cleaner than disable/enable? NW to try this approach.

mohrerao’s picture

@longwave, @Jungle, I would say keeping few lines at the beginning of the file would be a good idea where in we can list the ignored words for that file. This will address the maintainability as well as clean code

mohrerao’s picture

Status: Needs work » Needs review
FileSize
2.19 KB
5.5 KB

Adding a patch as per my suggestion in #13. Seeting to NR for review.

jungle’s picture

Status: Needs review » Needs work

Re #14: The patch in #14 is no difference with the patch #9 or it's a copy of the patch in #9.

mohrerao’s picture

@Jungle. Apologies for that. I was asking what if we add these specific words at the begininng of the file as per https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell...?
I agree this would also have some maintainability issue if code were removed, but if new code is added which again uses these words, then we will have to keep repeating ignore or disable.

Thanks.

jungle’s picture

Issue tags: +Needs reroll
+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
@@ -11,6 +11,11 @@
+// cSpell:ignore adbin adnum adrelid attisdropped attname attnum attrdef
+// cSpell:ignore attrelid atttypid atttypmod conkey conrelid contype

Well. This way is accepted in #3155463: Fix spelling error in Drupal\filter\Plugin\migrate\process\FilterID::getSourceFilterType(), and @alexpott commented that it's better. But needs a reroll.

jameszhang023’s picture

longwave’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
3.74 KB
2.94 KB

Thanks for rerolling.

To be consistent with #3155463: Fix spelling error in Drupal\filter\Plugin\migrate\process\FilterID::getSourceFilterType() I think we should place the ignore lines after the namespace and use statements.

I also identified a number of other Postgres specific words in this file that can be ignored, some of which can also be removed from the dictionary. Finally we can also get rid of "nullaction" by renaming a variable.

jameszhang023’s picture

@longwave, Thank you for the improvement.

longwave’s picture

We can remove three more Postgres words and "simpletests" as well - 33 words in total now - if we consider the entire Postgres driver to be in scope here.

jungle’s picture

+++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
@@ -6,6 +6,12 @@
+// cSpell:ignore attrelid atttypid atttypmod bigserial conkey conname conrelid

+++ b/core/misc/cspell/dictionary.txt
@@ -327,10 +315,8 @@ configurability
 conname

conname is ignored, but not being removed from the dictionary. Because it exists in core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlSchemaTest.php.

Fixing. Then 34 in total. As this is a less than 1KB change. Will back and set to RTBC once CI run finishes.

longwave’s picture

@jungle thanks for catching that one!

jungle’s picture

Status: Needs review » Reviewed & tested by the community

Testing is green. no CS violations. Setting to RTBC.

jungle’s picture

Issue tags: +Needs reroll
jungle’s picture

Status: Reviewed & tested by the community » Needs work
ravi.shankar’s picture

Assigned: Unassigned » ravi.shankar
ravi.shankar’s picture

Assigned: ravi.shankar » Unassigned
Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
6.57 KB

I have added a reroll of patch #22.

longwave’s picture

Status: Needs review » Reviewed & tested by the community
longwave’s picture

Rerolled

quietone’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs issue summary update

I read the IS and then skimmed the patch and was surprised to find that 'simpletests' and 'nullaction' are changed even though they are not PostgreSQL specific keywords. Since this patch is doing something different than stated in the IS the IS should be updated to state what this patch is actually doing. From my brief read it appears to be fixing all spelling errors in Core/Database/driver/pgsql and related tests.

jungle’s picture

  1. +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
    @@ -258,7 +260,7 @@ public function mapConditionOperator($operator) {
    -    // because the prefix may change, for example, like it does in simpletests.
    +    // because the prefix may change, for example, like it does in tests.
    

    simpletests in comment

    +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
    @@ -945,12 +952,12 @@ public function changeField($table, $field, $field_new, $spec, $new_keys = []) {
    -        $nullaction = 'SET NOT NULL';
    +        $null_action = 'SET NOT NULL';
    

    nullaction as a variable name.

  2. This is a part of #3122088: [Meta] Remove spelling errors from dictionary.txt and fix them. To me, the IS here is ok and its IS does not have to be as clear as other generic issues.
  3. Needs reroll
longwave’s picture

Title: Disable spell checking for PostgreSQL specific keywords » Fix or ignore 33 words only used in the PostgreSQL driver
Status: Needs work » Needs review
FileSize
6.45 KB

Rerolled, also improved title as per #31

daffie’s picture

Issue tags: -Needs reroll

Patch was rerolled.

jungle’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs followup

Thanks @longwave!

  1. +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
    @@ -8,6 +8,8 @@
    +// cSpell:ignore ilike nextval
    
    +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php
    @@ -5,6 +5,8 @@
    +// cSpell:ignore nextval setval
    
    +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
    @@ -6,6 +6,12 @@
    +// cSpell:ignore adbin adnum adrelid adsrc attisdropped attname attnum attrdef
    +// cSpell:ignore attrelid atttypid atttypmod bigserial conkey conname conrelid
    ...
    +// cSpell:ignore schemaname setval
    
    @@ -566,6 +572,7 @@ public function renameTable($table, $new_name) {
    +      // cSpell:disable-next-line
    
    +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php
    @@ -4,6 +4,8 @@
    +// cSpell:ignore nextval setval
    +
    
    +++ b/core/tests/Drupal/Tests/Core/Database/Driver/pgsql/PostgresqlSchemaTest.php
    @@ -5,6 +5,8 @@
    +// cSpell:ignore conname
    

    cspell:ignore used. Both cSpell:ignore and cspell:ignore are valid, and have usages committed. Needs a follow-up to unify them to keep consistent? Tagging "Needs followup"

  2. +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php
    @@ -258,7 +260,7 @@ public function mapConditionOperator($operator) {
    -    // because the prefix may change, for example, like it does in simpletests.
    +    // because the prefix may change, for example, like it does in tests.
    

    Comment rewritting.

  3. +++ b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php
    @@ -945,12 +952,12 @@ public function changeField($table, $field, $field_new, $spec, $new_keys = []) {
    -        $nullaction = 'SET NOT NULL';
    +        $null_action = 'SET NOT NULL';
    ...
           }
    

    Variable renaming

  4. $ yarn spellcheck:core
    yarn run v1.22.4
    $ cspell "**/*" "../composer/**/*" "../composer.json"
    CSpell: Files checked: 14640, Issues found: 0 in 0 files
    ✨  Done in 251.54s.
    

All are good to me.

  • catch committed c1e8435 on 9.1.x
    Issue #3154669 by longwave, jungle, mohrerao, jameszhang023, ravi....
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed c1e8435 and pushed to 9.1.x. Thanks!

Status: Fixed » Closed (fixed)

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

quietone’s picture

Issue tags: -Needs followup

Follow up made, #3305090: Should core use cspell or cSpell . Removing tag