Golinters


#1

Recently we’ve been using linters to improve the code quality of the Juju codebase, with the employment of the following:

  • gofmt - ensures that the formatting rules of every go file is the same
  • goimports - the imports of a gofile are correct
  • misspell - removes some very basic spelling errors
  • unconvert - removes unnecessary type conversions
  • govet - reports suspicious constructs

Recently we used gometalinter to solve these requirements, but unfortunately gometalinter has been deprecated and is no longer being maintained. It recommends that golangci-lint is used as a successor and I’ve just converted the Juju codebase over to this new linter.

If anything is wrong or isn’t quite working as expected, then please let me know so I can fix it.


#2

If anyone wants to see anymore linters added, then please let me know and I’ll see what’s possible.


#3

What might be interesting is that we could use --new-from-rev="HEAD~$(git rev-list develop.. --count)" which will test all the linters against only new code that is written, rather than legacy code that we have.