Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 5021: Add a script to fix spelling errors with codespell #565

Closed
wants to merge 11 commits into from
58 changes: 58 additions & 0 deletions scripts/codespell-whitelist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
actuall
agains
aline
alloced
anid
ans
aparent
backword
backwords
cachable
cas
childs
commend
crypted
dont
fo
followings
formater
hight
hist
iff
inactivate
initate
nd
neeed
nnumber
normall
othere
pasttime
performes
pevents
pointes
preceed
querys
readed
referer
retuned
sence
sheme
tage
te
tha
ther
therefor
thru
thur
tim
tread
tthe
ue
uint
upto
vaid
valuse
whan
whe
wil
wnat
64 changes: 64 additions & 0 deletions scripts/spell-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/sh
#
## Copyright (C) 2020 The Squid Software Foundation and contributors
##
## Squid software is distributed under GPLv2+ license and includes
## contributions from numerous individuals and organizations.
## Please see the COPYING and CONTRIBUTORS files for details.
##

#
# This script runs codespell against selected files.
#

rousskov marked this conversation as resolved.
Show resolved Hide resolved
set -e

echo -n "Codespell version: "
if ! codespell --version; then
echo "This script requires codespell which was not found."
exit 1
fi

if ! git diff --quiet; then
echo "There are unstaged changes. Stage these first to prevent conflict."
exit 1
fi

WHITE_LIST=scripts/codespell-whitelist.txt
if test ! -f "${WHITE_LIST}"; then
rousskov marked this conversation as resolved.
Show resolved Hide resolved
echo "${WHITE_LIST} does not exist"
exit 1
fi

for FILENAME in `git ls-files "$@"`; do
# skip subdirectories, git ls-files is recursive
test -d $FILENAME && continue

case ${FILENAME} in

# skip (some) generated files with otherwise-checked extensions
doc/debug-sections.txt)
;;

# skip imported/foreign files with otherwise-checked extensions
doc/*/*.txt)
;;

# check all these
*.h|*.c|*.cc|*.cci|\
*.sh|\
*.pre|\
*.pl|*.pl.in|*.pm|\
*.dox|*.html|*.txt|\
*.sql|\
errors/templates/ERR_*|\
INSTALL|README|QUICKSTART)
if ! codespell -d -q 3 -w -I "${WHITE_LIST}" ${FILENAME}; then
echo "codespell failed for ${FILENAME}"
exit 1
fi
;;
esac
done

exit 0