For more information on staticcheck:
It looks like they have a commercial offering too so that we could sponsor development if we really like the tool.
staticcheck finds more than just missing errors.
A sample report from running it over the sensu-go codebase:
commands/asset/create_test.go:116:2: this value of asset is never used (SA4006)
commands/timeutil/time.go:81:31: calling strings.Replace with n == 0 will return no results, did you mean -1? (SA1018)
commands/timeutil/time.go:81:47: calling strings.Replace with n == 0 will return no results, did you mean -1? (SA1018)
agent.go:267:33: calling regexp.MatchString in a loop has poor performance, consider using regexp.Compile (SA6000)
agent.go:351:34: calling regexp.MatchString in a loop has poor performance, consider using regexp.Compile (SA6000)
agentd/agentd.go:89:34: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (SA1012)
apid/apid.go:104:34: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (SA1012)
dashboardd/dashboardd.go:91:34: do not pass a nil Context, even if a function permits it; pass context.TODO if you are unsure about which Context to use (SA1012)
keepalived/keepalived.go:320:58: argument event is overwritten before first use (SA4009)
Threre are more static checkers available for Go ( https://github.com/alecthomas/gometalinter will run a number of them.)
We're using gometalinter already, but are not using staticcheck yet. It's just a matter of adding it to the linter and then fixing all the problems. :)
I decided to call out to megacheck instead, and fixed a bunch of lint and removed a bunch of dead code. We still have an outstanding issue in that some packages are not lint-free and we punted on fixing them, but that can be cleaned up in another effort.
@echlebek Happy to mindnumbingly remove lint.
Little bit of stutter in the issue because of adding megacheck to the build script's go gets and forgot CHANGELOG.md entry.
Most helpful comment
staticcheck finds more than just missing errors.
A sample report from running it over the sensu-go codebase:
Threre are more static checkers available for Go ( https://github.com/alecthomas/gometalinter will run a number of them.)