On Mon, Jan 10, 2022 at 16:41:25 +0100, Tim Wiederhake wrote:
This is a wrapper for codespell [1], a spell checker for source
code.
Codespell does not compare words to a dictionary, but rather works by
checking words against a list of common typos, making it produce fewer
false positives than other solutions.
The script in this patch works around the lack of per-directory ignore
lists and some oddities regarding capitalization in ignore lists.
[1] (
https://github.com/codespell-project/codespell/)
Signed-off-by: Tim Wiederhake <twiederh(a)redhat.com>
---
scripts/check-spelling.py | 119 ++++++++++++++++++++++++++++++++++++++
1 file changed, 119 insertions(+)
create mode 100755 scripts/check-spelling.py
diff --git a/scripts/check-spelling.py b/scripts/check-spelling.py
new file mode 100755
index 0000000000..0480a506e8
--- /dev/null
+++ b/scripts/check-spelling.py
@@ -0,0 +1,119 @@
+#!/usr/bin/env python3
+
+import argparse
+import re
+import subprocess
+import os
+
+
+IGNORE_LIST = [
+ # ignore all translation files
+ ("/po/", []),
+
+ # ignore all git files
+ ("/.git/", []),
IMO this should be working on an equivalent of 'git ls-files' rather
than excluding files which _might_ interfere as if you run it in a
not-so-clean checkout it also looks for files which are not part of the
repo:
$ ./scripts/check-spelling.py
("/tags", "aLocation"), # line 10516, "allocation"?
("/tags", "aLocation"), # line 10517, "allocation"?
("/tags", "aLocation"), # line 10518, "allocation"?
("/tags", "aLocation"), # line 10521, "allocation"?
("/tags", "aLocation"), # line 10522, "allocation"?
("/tags", "aLocation"), # line 10523, "allocation"?
("/tags", "aLocation"), # line 10526, "allocation"?
("/tags", "aLocation"), # line 10527, "allocation"?
("/tags", "aLocation"), # line 10528, "allocation"?
("/tags", "independant"), # line 48256, "independent"?
("/tags", "parm"), # line 60938, "param, pram, parma"?
("/tags", "parm"), # line 60938, "param, pram, parma"?
("/tags", "calld"), # line 80099, "called"?
("/tests/qemucapabilitiesnumbering.c", "occurence"), # line 60,
"occurrence"?
("/tests/virstoragetest.c.orig", "folowing"), # line 103,
"following"?
("/tests/qemucapabilitiestest.c", "programatic"), # line 216,
"programmatic"?
error: 16 spelling errors
'tags' is a file generated by 'ctags' and
"/tests/virstoragetest.c.orig"
is an artifact of an editor.
Also since the script is lacking integration with meson and is also
missing from documentation it's not applied to local builds, only on
stuff that gets CI'd. Catching these early will hopefully prevent a few
pointless CI runs just to fix typos.