Skip to content

golangci-lint doesn't seem to make use of RelatedInformation #1189

Closed
@mpictor

Description

@mpictor

Thank you for creating the issue!

  • Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
  • Yes, I've searched similar issues on GitHub and didn't find any.
  • Yes, I've included all information below (version, config, etc).

Please include the following information:

Version of golangci-lint
$ golangci-lint --version
golangci-lint has version 1.27.0 built from fb74c2e on 2020-05-13T18:48:26Z
Config file

N/A

Go environment
$ go version && go env
go version go1.14.1 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/mark/.cache/go-build"
GOENV="/home/mark/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/mark/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build017019077=/tmp/go-build -gno-record-gcc-switches"

See the last comments on dominikh/go-tools#641

Copying Dominik's response here:

when running staticcheck on this function

func fn(x *byte) {
	println(*x)
	if x != nil {
		return
	}
}

it outputs the following diagnostic

foo.go:4:10: possible nil pointer dereference (SA5011)
	foo.go:5:5: this check suggests that the pointer can be nil

pointing at both the dereference, as well as the relevant nil pointer check.

It seems that golangci-lint neglects to point at the actual check:

foo.go:4:10: SA5011: possible nil pointer dereference (staticcheck)
	println(*x)

This is an issue in golangci-lint, not staticcheck. In go/analysis terms, golangci-lint doesn't seem to make use of RelatedInformation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions