codespell-project / codespell

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

--skip doesn't work #2047

Open DimitriPapadopoulos opened 2 years ago

DimitriPapadopoulos commented 2 years ago

I might be doing something stupid, but I cannot find a way to skip these files or folders:

tests/ci/checkpatch/spelling.txt
tests/ci/checkpatch/
.git/

I have tried the three variants -S, --skip, --skip= and all these forms:

--skip ./tests/ci/checkpatch/spelling.txt
--skip tests/ci/checkpatch/spelling.txt
--skip ./tests/ci/checkpatch/
--skip ./tests/ci/checkpatch
--skip tests/ci/checkpatch/
--skip tests/ci/checkpatch
--skip ./.git/
--skip ./.git
--skip .git/
--skip .git

The only thing that seems to be working for tests/ci/checkpatch/spelling.txt is:

--skip spelling.txt
bwitt commented 2 years ago

I think this is related to https://github.com/codespell-project/codespell/issues/1915

vikivivi commented 2 years ago

Creating a test environment.

mkdir -p test/.git
mkdir -p test/.svn
mkdir -p test/log
mkdir -p test/inc
mkdir -p test/src
mkdir -p test/res
cd test/
echo abotu >> .git/test.txt
echo abotu >> .svn/test.txt
echo abotu >> src/my-test.c
echo abotu >> inc/my-test.h
echo abotu >> res/test.jpg
echo abotu >> res/test.png
echo abotu >> log/test.log

Here is my test results without --skip

codespell 
./log/test.log:1: abotu ==> about
./src/my-test.c:1: abotu ==> about
./res/test.png:1: abotu ==> about
./res/test.jpg:1: abotu ==> about
./inc/my-test.h:1: abotu ==> about

My test results after adding --skip

codespell --skip=.git,log,*.png,*.jpg,inc
./src/my-test.c:1: abotu ==> about

codespell --skip .git,log,*.png,*.jpg,inc
./src/my-test.c:1: abotu ==> about

codespell -S .git,log,*.png,*.jpg,inc
./src/my-test.c:1: abotu ==> about

It seem to me that it is unable to handle sub-directory slash in --skip well.

mkdir -p src/3rd-party
mkdir -p inc/3rd-party
echo abotu >> src/3rd-party/test.c
echo abotu >> inc/3rd-party/test.h

codespell -S .git,src/3rd-party,log,*.png,*.jpg,inc
./src/my-test.c:1: abotu ==> about
./src/3rd-party/test.c:1: abotu ==> about
DimitriPapadopoulos commented 2 years ago

Indeed, --skip .git does work after all. Probably an issue with / as you write.

vikivivi commented 2 years ago

@DimitriPapadopoulos To skip sub-directory, you will need to start with ./

DimitriPapadopoulos commented 2 years ago

Yes, I've just noticed that. Do you agree it's a nuisance? I plan on fixing it.