go-tools icon indicating copy to clipboard operation
go-tools copied to clipboard

doc comments with wrong function names, maybe?

Open seebs opened this issue 6 years ago • 2 comments

$ 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.

seebs avatar Nov 07 '19 19:11 seebs

Note that golint does this for exported functions: https://github.com/golang/lint/blob/master/lint.go#L475

dgryski avatar Nov 07 '19 19:11 dgryski

Is this fixed by https://staticcheck.dev/docs/checks/#ST1020 ?

TomOnTime avatar Feb 11 '22 15:02 TomOnTime

Is this fixed by https://staticcheck.dev/docs/checks/#ST1020 ?

I believe so, yes.

dominikh avatar Jun 26 '23 17:06 dominikh

Hmmm... I don't think this is fixed. I deleted the comment above an exported function and staticcheck didn't report anything.

TomOnTime avatar Jun 28 '23 17:06 TomOnTime

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.

dominikh avatar Jun 28 '23 19:06 dominikh