Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: vet and staticcheck return "same" diagnostic #34494

Closed
myitcv opened this issue Sep 24, 2019 · 8 comments
Closed

x/tools/gopls: vet and staticcheck return "same" diagnostic #34494

myitcv opened this issue Sep 24, 2019 · 8 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@myitcv
Copy link
Member

myitcv commented Sep 24, 2019

What version of Go are you using (go version)?

$ go version
go version devel +c3c53661ba Tue Sep 17 04:37:46 2019 +0000 linux/amd64
$ go list -m golang.org/x/tools
golang.org/x/tools v0.0.0-20190923183622-59c6680fe2c1
$ go list -m golang.org/x/tools/gopls
golang.org/x/tools/gopls v0.0.0-20190923183622-59c6680fe2c1

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/myitcv/.cache/go-build"
GOENV="/home/myitcv/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/myitcv/gos"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/myitcv/gostuff/src/github.com/myitcv/govim/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build538251118=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Running with staticcheck turned on.

With the following file:

package main

import "fmt"

func main() {
	fmt.Printf("%s")
}

the following "identical" diagnostics are returned:

PublishDiagnostics callback: &protocol.PublishDiagnosticsParams{
    URI:         "file:///home/myitcv/gostuff/src/github.com/myitcv/playground/main.go",
    Version:     0,
    Diagnostics: {
        {
            Range: protocol.Range{
                Start: protocol.Position{Line:5, Character:1},
                End:   protocol.Position{Line:5, Character:1},
            },
            Severity:           2,
            Code:               nil,
            Source:             "printf",
            Message:            "Printf format %s reads arg #1, but call has 0 args",
            Tags:               nil,
            RelatedInformation: nil,
        },
        {
            Range: protocol.Range{
                Start: protocol.Position{Line:5, Character:11},
                End:   protocol.Position{Line:5, Character:11},
            },
            Severity:           2,
            Code:               nil,
            Source:             "SA5009",
            Message:            "Printf format %s reads arg #1, but call has only 0 args",
            Tags:               nil,
            RelatedInformation: nil,
        },
    },
}

What did you expect to see?

Just one diagnostic reporting the missing argument.

What did you see instead?

Two, as above.


cc @stamblerre @ianthehat

@myitcv myitcv added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. gopls Issues related to the Go language server, gopls. labels Sep 24, 2019
@myitcv myitcv added this to the gopls v1.0 milestone Sep 24, 2019
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 24, 2019
@stamblerre
Copy link
Contributor

Thanks for reporting. I guess the correct solution would be to maintain some set of duplicate checks. Deduping these diagnostics as we see them wouldn't work because they may have differently worded messages, etc.

Should we disable vet checks that are provided by staticcheck or vice versa?

@stamblerre stamblerre changed the title x/tools/cmd/gopls: vet and staticcheck return "same" diagnostic x/tools/gopls: vet and staticcheck return "same" diagnostic Sep 25, 2019
@myitcv
Copy link
Member Author

myitcv commented Sep 25, 2019

Should we disable vet checks that are provided by staticcheck or vice versa?

I seem to recall from Slack the other day, @dominikh mentioning that he plans to effectively subsume all vet checks in staticcheck. But I'll leave up to you all to decide which is the source of truth :)

@dominikh
Copy link
Member

That is indeed the plan, but it is a long-term plan for me. And, of course, vet will continue to gain new checks, too, so I wouldn't simply replace vet with staticcheck in gopls.

Maintaining a list of duplicate checks sounds like the correct approach. Deciding which implementation of a check to use will be the hard part. Some checks are better in staticcheck, some are better in vet… And the list will need to be kept in sync as either vet or staticcheck gain new checks that overlap.

@dominikh
Copy link
Member

Also, this issue extends to golint as well.

@stamblerre stamblerre modified the milestones: gopls v1.0, gopls unplanned Dec 4, 2019
@myitcv
Copy link
Member Author

myitcv commented Jan 16, 2020

@stamblerre just wondering whether this is small enough to try and fix for v1.0.0? It's a bit of an annoyance to have double entries in the diagnostics.

@stamblerre
Copy link
Contributor

Is it just this check that's a duplicate or are there others? I can hardcode something if it's just a few.

@myitcv
Copy link
Member Author

myitcv commented Jan 16, 2020

I've only seen this one to date.

@gopherbot
Copy link

Change https://golang.org/cl/215118 mentions this issue: gopls/internal/hooks: ignore a duplicate analysis from staticcheck

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

5 participants