评论:
arp242:
Bake_Jailey:I run these in my editor, as they're reasonably fast:
--enable=vet --enable=errcheck --enable=golint --enable=ineffassign --enable=goimports --enable=lll --line-length=120
I run these on CI for most projects. They're not fast enough to run in the editor, but still useful enough to catch the occasional issue:
--enable=varcheck --enable=interfacer --enable=unconvert --enable=structcheck --enable=megacheck
dlsniper:
gometalinter --enable-all
I'm a madman.
Bake_Jailey:The problem is that some of those are useless, like gas, or produce too many false positives to be useful, like errorcheck.
I use GoLand, which has its own linters, but before commits I run go vet, golint, and megacheck.
dlsniper:All of that is true. I did say it was mad.
I usually disable gas, the sql checker, as well as the line length checker, plus extra filtering to deal with linters which descend into vendor without being asked.
I'm not so sure about false positives from errorcheck. If you mean errors from close functions, I'd rather handle those than not.
Bake_Jailey:Yes, but I'm sure nobody handles errors from fmt.Printf, for example.
Also your comment about disabling linters doesn't make sense since the previous comment says you enable them all...
arp242:I've never had gometalinter show me a warning for fmt, even with everything enabled.
And I guess "I'm a madman" wasn't a strong enough hint that my answer wasn't completely serious.
mikolaj:produce too many false positives to be useful, like errorcheck.
errcheck doesn't give me that many problems? The most common cases are either
Close()
where you're doing a read-only operation, or someWrite()
calls. It's not that common. You can also easily disable it with:defer f.Close() // nolint: errcheck
Or for an entire function:
// nolint: errcheck func Foo() { }
It's a bit ugly, but in the past we've had a lot of people ignoring error checks (especially in tests) which caused all sorts of issues.
cs-guy:gometalinter with following linters: golint, gotype, deadcode
go vet, golint, and megacheck
