codespell-project / codespell

check code for common misspellings
GNU General Public License v2.0
1.9k stars 467 forks source link

`--ignore-words` should itself be a `--skip` implicitly #3293

Open Alexander-Shukaev opened 9 months ago

Alexander-Shukaev commented 9 months ago

As per title, otherwise codespell fixes the ignore file itself which makes no sense anyway.

DimitriPapadopoulos commented 9 months ago

I actually tested that very use case yesterday in the context of #3206, and it worked for me:

$ mkdir test
$ cd test
/tmp/test
$ 
$ cat > aare.txt
aare
$ codespell .
aare.txt:1: aare ==> are
$ 
$ cat > aadd.txt
aadd
$ codespell .
./aadd.txt:1: aadd ==> add
./aare.txt:1: aare ==> are
$ 
$ cat > ignore.txt 
aare
aadd
$ codespell .
./aadd.txt:1: aadd ==> add
./aare.txt:1: aare ==> are
./ignore.txt:1: aare ==> are
./ignore.txt:2: aadd ==> add
$ 
$ codespell --ignore-words ignore.txt .
$ 

There are two ways to handle such a situation:

  1. Since --ignore-words lists the word to ignore, these words will be ignored, including in the files passed as argument to --ignore-words. No real need to skip these files.
  2. Make sure these files are not even read. That's probably the right thing to do.

I guess codespell uses mechanism 1. The right thing to do would be to switch to mechanism 2, but this would require other PRs such as #2058 to be merged first. So let's stick to mechanism 2 for now. I guess your issue is a case issue similar to #3248. You should be able to take care of it by fixing the case of the words to ignore, or by testing master branch that includes recent PR #3272.

Does this help?