Created
February 28, 2021 19:10
-
-
Save jehiah/487faef2d572057a76eaef3fd4ccb9d1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# run https://github.com/client9/misspell linter | |
SCRIPT=$(readlink -f "$0") | |
SCRIPTPATH=`dirname "$SCRIPT"` | |
# get to repo root | |
cd $SCRIPTPATH/../../.. | |
WRITE="" | |
while [ "$1" != "" ]; do | |
PARAM=${1%%=*} | |
VALUE=${1#*=} | |
case $PARAM in | |
-w) | |
WRITE="-w" | |
;; | |
*) | |
echo "extra param \"$PARAM\"" | |
exit 1 | |
;; | |
esac | |
shift | |
done | |
if [ ! -e /bitly/local/bin/misspell ]; then | |
echo "missing /bitly/local/bin/misspell" | |
echo "run ./deploy.sh (or install_misspell.sh)" | |
exit 1 | |
fi | |
# NOTE: rules are always lower case | |
IGNORE_RULES="incrementers,auther,cancelled,cancelling,marshalling,marshalled" | |
# ^^^^^ | |
# ^^^^^ | |
# Add false positive rules to this list | |
# alternatively ignore all matches on specific files with ignore_misspell_files.csv | |
# ################################################################################# | |
set -o pipefail | |
OUTPUT=$(find . \( -name '*.go' -or -name '*.md' -or -name '*.js' -or -name '*.tsx' -or -name '*.py' -or -name '*.sh' \) | \ | |
grep -v -f $SCRIPTPATH/ignore_misspell_files.csv | \ | |
xargs -n 5000 misspell -locale US -error -i ${IGNORE_RULES} ${WRITE}) | |
EXIT_CODE=$? | |
if [ $EXIT_CODE != "0" ] || [ "$OUTPUT" != "" ]; then | |
cat << EOF | |
Error: $(echo "${OUTPUT}" | wc -l) possible misspellings detected | |
False positives can be handled by either of the following | |
a) Ignore the match pattern in infrastructure/tests/misspell/test.sh | |
b) Ignore the source file with infrastructure/tests/misspell/ignore_misspell_files.csv | |
Tip: to attempt to automatically apply these changes run 'infrastructure/tests/misspell/test.sh -w' | |
${OUTPUT} | |
EOF | |
exit 1 | |
fi | |
echo "misspell: OK no misspellings detected" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment