きっかけ
開発中案件でpaymentがpaymantになっている事件が発覚したため。
GNU Aspellでさっくりとチェックかけたいな、と思った。
前期: せめてファイル名だけでもきちんとしたい
Aspell導入
CentOSならyumでさっくり入る。
$ sudo yum install aspell-en
$ echo "lang en_US" > ~/.aspell.conf
チェックしてみる
$ cd path/to/files
$ find . -type f |sed "s/[A-Z][a-z]/ \0/g" | tr '[A-Z]' '[a-z]' |aspell list |sort|uniq
といった感じで実行して、
ajax
ami
ansible
apache
auth
bowerrc
btn
cli
colorbox
commom
conf
config
configs
const
consts
css
csv
(以下略)
直す
怪しいのを見つけたらgrepして、必要に応じて置換。
find . -type f -print | xargs grep -l typo_word | xargs sed -i "s/typo_word/correct_word/g";
あるいはgit-gsubを使って
git gsub typo_word correct_word
結果
commomなどが発掘され、平和が訪れたような気がした。
後期: さらに見つかり
ソースコード内の変数の中にbirthbayが埋もれていたりしたので、カッとなった。
改良してチェック
find . -type f -print |xargs file |grep text |awk -F' ' '{print $1}' |sed -e 's/://g' |xargs cat |sed "s/[A-Z][a-z]/ \0/g" |tr '[A-Z]' '[a-z]' |aspell list |sort|uniq
catで開いて、中身までチェック。
結果
俺たちの戦いはまだ終わっていなかったりするし、次回作なんていらない。
まとめ
さっくりじゃなくなってきたので、ぼちぼち違う手法を使おうと思っている。