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

Open
myitcv opened this issue Sep 24, 2019 · 4 comments

Comments

@myitcv
Copy link
Member

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

@stamblerre

This comment has been minimized.

Copy link
Contributor

commented Sep 25, 2019

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

This comment has been minimized.

Copy link
Member Author

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

This comment has been minimized.

Copy link
Member

commented Sep 25, 2019

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

This comment has been minimized.

Copy link
Member

commented Sep 27, 2019

Also, this issue extends to golint as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.