doc comments with wrong function names, maybe?
$ staticcheck -version
staticcheck 2019.2.3
$ staticcheck -debug.version
staticcheck 2019.2.3
Compiled with Go version: go1.13
Main module:
honnef.co/go/[email protected] (sum: h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM=)
Dependencies:
github.com/BurntSushi/[email protected] (sum: h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=)
golang.org/x/[email protected] (sum: h1:MQEvx39qSf8vyrx3XRaOe+j1UDIzKwkYOVObRgGPVqI=)
$ go version
go version go1.13 linux/amd64
[go env large and probably irrelevant]
So, I ran staticcheck on a thing, and it was happy. Then a reviewer spotted something like:
// someOtherFunction doc comment
func aFunctionWhichGotRenamed() {
...
It occurs to me that a linter could conceivably catch this, but oddly, none of them do.
It might make sense to restrict a check to cases in which the comment looks like a doc comment for an existing function, but in the specific case I did this in, there wasn't still another function, this was just a function that I renamed without spotting the doc comment.
Note that golint does this for exported functions: https://github.com/golang/lint/blob/master/lint.go#L475
Is this fixed by https://staticcheck.dev/docs/checks/#ST1020 ?
Is this fixed by https://staticcheck.dev/docs/checks/#ST1020 ?
I believe so, yes.
Hmmm... I don't think this is fixed. I deleted the comment above an exported function and staticcheck didn't report anything.
They are optional checks that need to be enabled explicitly. Furthermore, they flag incorrect comments, not missing comments. We don't intend to flag missing comments.