Skip to content

Instantly share code, notes, and snippets.

@dmiedema
Last active April 26, 2016 21:43
Show Gist options
  • Save dmiedema/29551d0fbcb73538569b to your computer and use it in GitHub Desktop.
Save dmiedema/29551d0fbcb73538569b to your computer and use it in GitHub Desktop.
Add warnings in Xcode for misspelled words.
#!/usr/bin/env bash
export COMMON_MISSPELLED_WORDS=(\
# Can be partial words
' fro ' \
' sting ' \
' teh ' \
' wer ' \
# Okay with partial word matches
'characterstic' \
'configuation' \
'contorller' \
'contrller' \
'decive' \
'devicie' \
'nagivation' \
'occured' \
'pasword' \
'recieved' \
'scaned' \
'signle' \
'titel' \
'uesr' \
)
#!/usr/bin/env bash
source common_misspelled_words.sh
for WORD in "${COMMON_MISSPELLED_WORDS[@]}"; do
grep --recursive \
--ignore-case \
--fixed-strings \
--with-filename \
--line-number \
--only-matching \
--binary-file=without-match \
--exclude '*.md' \
--exclude '*.sh' \
--exclude-dir '.git' \
--exclude-dir '[Proejct].xcodeproj' \
--exclude-dir 'Fonts' \
--exclude-dir 'Frameworks' \
--exclude-dir 'Libraries' \
--exclude-dir 'Settings.bundle' \
--exclude-dir 'en.lproj' \
"$WORD" "$SRCROOT" | perl -p -e "s/($WORD)/ warning: $WORD/i" &
done
wait
@dmiedema
Copy link
Author

~/Code/Project master* 10s
[0] ❯ time ./spell_check_parallel.sh
./spell_check_parallel.sh  4.41s user 0.06s system 99% cpu 4.468 total

~/Code/Project master*
[0] ❯ time ./spell_check.sh         
./spell_check.sh  34.00s user 0.42s system 763% cpu 4.508 total

¯_(ツ)_/¯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment