Header Ads

Spell Checking Your Programming from the Linux Command Line

For most of us who didn’t do well in high school English class, spell checkers are a real game-changer. Sure, you can still swap a “to” and a “too,” but a spell checker will catch a lot of typos. But what about in your source code? You usually don’t spell check source code and even if you did, the rules are funny. After all, “my_proejct” is a perfectly fine variable name, but you probably meant “my_project.” That’s where a program called typos comes in. It aims to be a spell checker for source code that is fast enough and with a low enough false positive rate that you can run it against changed code and reject spelling problems.

Sure, if “my_proejct” is a one-time typo, the compiler or interpreter will probably catch it. But it won’t catch comments and it also won’t catch something you spell wrong consistently. For that you need something like typos.

You can include a custom dictionary and also per-language dictionaries. It is aware of camel case and snake case and knows to ignore hex codes. The only thing we saw it doesn’t handle well is C-language escapes.

There are apparently other checkers out there and we learned about them from this project’s comparison grid. There’s misspell, codespell, and scspell. This is the tool we didn’t know we needed, but probably do.

If you are writing bash scripts and want to check their correctness there is shellcheck, which sounds like spell check but has a whole different function. If you want to brush up on your spelling, you can always hack a Speak ‘n Spell.


No comments