dominikh / go-tools

Staticcheck - The advanced Go linter
https://staticcheck.dev
MIT License
6.01k stars 361 forks source link

"//lint:ignore U1000 comment" does not work anymore #1537

Closed ohir closed 1 month ago

ohir commented 1 month ago

Bug was spotted under VSCode, repro is from console. It was v0.4.6, updated for test to v0.4.7 I noticed that the U1000 likely was present in the messages, but now it is not to be seen. Repro has file-ignore, but function level ignore does not work too.

repro

cat scktest.go && echo '//--->>>' && staticcheck . ; echo -e "<<<---\n\n" ; staticcheck -version ;staticcheck -debug.version && go version

//lint:file-ignore U1000 WiP
package bad

func A() {
    var i int
}
//--->>>
-: # fairbe.org/sckbug/bad
./scktest.go:5:6: i declared and not used (compile)
zsh: exit 1     staticcheck .
<<<---

staticcheck 2023.1.7 (v0.4.7)
staticcheck 2023.1.7 (v0.4.7)

Compiled with Go version: go1.22.3
Main module:
    honnef.co/go/tools@v0.4.7 (sum: h1:9MDAWxMoSnB6QoSqiVr7P5mtkT9pOc1kSxchzPCnqJs=)
Dependencies:
    github.com/BurntSushi/toml@v1.2.1 (sum: h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=)
    golang.org/x/exp/typeparams@v0.0.0-20221208152030-732eee02a75a (sum: h1:Jw5wfR+h9mnIYH+OtGT2im5wV1YGGDora5vTv/aa5bE=)
    golang.org/x/mod@v0.12.0 (sum: h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=)
    golang.org/x/sys@v0.11.0 (sum: h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=)
    golang.org/x/tools@v0.12.1-0.20230825192346-2191a27a6dc5 (sum: h1:Vk4mysSz+GqQK2eqgWbo4zEO89wkeAjJiFIr9bpqa8k=)
go version go1.22.3 darwin/amd64

Env:

GO111MODULE='' # all other empty and irrelevant are filtered out, some paths {cut}
GOARCH='amd64'
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOOS='darwin'
GOPATH='{cut}/src' # module is NOT in the gopath
GOROOT='{cut}'
GOSUMDB='sum.golang.org'
GOTMPDIR='{cut}/TEMP/go'
GOTOOLCHAIN='auto'
GOTOOLDIR='{cut}/pkg/tool/darwin_amd64'
GOVERSION='go1.22.3'
GCCGO='gccgo'
GOAMD64='v1'
GOMOD='{cut}/scf/go.mod'
GOWORK=''  # bug was spotted in a workspace tree, does not affect the repro
dominikh commented 1 month ago

This is unrelated to Staticcheck; unused local variables are a compiler error.