Ned's Linter advice

A few weeks back Ned Haughton posted a tip about linters that was so useful we thought we would share it in out latest newsletter.

Ned wrote: 

If you aren't already using a linter for your code, you should look in to it. They exist for most languages, and most major text editors and IDEs, and really help to keep your code consistent and easy to read, and can also help remove some bugs before you even run the code.

Linters run static code analysis, which basically means checking the code itself, rather than detecting errors at run time. They look for syntax errors and coding-style inconsistencies (e.g. python not following the coding standards in PEP8, or R not following Hadley Wickham's style guide), and some can also do things like highlight undefined or unused variables, or detect array out-of-bounds errors.

Major language linters:

For most major editors/IDEs (Vim, Emacs, Sublime, Atom, Rstudio, etc.), these linters can be run on code while you're editing, and will highlight problems, and also explain why they're highlighting them –  like

For Vim, you need syntastic ( 

For other editors, you may need to enable plugins or change settings. If it's not obvious, your best bet is generally a web search for "<editor> lint <language>"

* I haven't actually managed to get a fortran linter working yet.

UNSW logo ANU logo Monash logo UMelb logo UTAS logo