Skip to content

unused false positive on master #2771

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

Closed
4 tasks done
andig opened this issue Apr 17, 2022 · 4 comments · Fixed by #2772
Closed
4 tasks done

unused false positive on master #2771

andig opened this issue Apr 17, 2022 · 4 comments · Fixed by #2772
Labels
bug Something isn't working

Comments

@andig
Copy link

andig commented Apr 17, 2022

Welcome

  • 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).
  • Yes, I've tried with the standalone linter if available. (https://golangci-lint.run/usage/linters/)

Description of the problem

These are false positives:

gor github.com/golangci/golangci-lint/cmd/golangci-lint@master run
WARN [linters context] structcheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649.
provider/cache.go:31:2: field `g` is unused (unused)
	g       func() (T, error)
	^
provider/cache.go:32:2: field `val` is unused (unused)
	val     T
	^
exit status 1

Version of golangci-lint

$ golangci-lint --version
golangci-lint has version v1.45.3-0.20220417134108-333187c0664f built from (unknown, mod sum: "h1:I4w1Eokzoj09iR+nPWSp6+tZlvo5cGkdOVsAnd+aiGo=") on (unknown)

Configuration file

$ cat .golangci.yml
run:
  go: 1.18
issues:
  exclude:
    - .regActualCurrent. is unused
    - "`routeLogger` is unused"
linters-settings:
  staticcheck:
    checks:
      - "-SA1019"

Go environment

$ go version && go env
o version go1.18.1 darwin/arm64
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/andig/Library/Caches/go-build"
GOENV="/Users/andig/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/andig/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andig/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.18.1/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.18.1/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/andig/htdocs/evcc/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-build11488543=/tmp/go-build -gno-record-gcc-switches -fno-common"

Verbose output of running

$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /Users/andig/htdocs/evcc /Users/andig/htdocs /Users/andig /Users /]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 10 linters: [deadcode errcheck gosimple govet ineffassign staticcheck structcheck typecheck unused varcheck]
INFO [loader] Go packages loading at mode 575 (compiled_files|imports|name|deps|exports_file|files|types_sizes) took 1.277977167s
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 13.421709ms
INFO [linters context/goanalysis] analyzers took 33.165556009s with top 10 stages: buildir: 23.304828938s, inspect: 1.648649944s, printf: 1.188335614s, ctrlflow: 1.130665824s, directives: 445.414454ms, S1038: 401.027255ms, isgenerated: 251.778795ms, varcheck: 247.206999ms, errcheck: 192.879324ms, unused: 189.092751ms
WARN [linters context] structcheck is disabled because of go1.18. You can track the evolution of the go1.18 support by following the https://github.com/golangci/golangci-lint/issues/2649.
INFO [runner] Issues before processing: 43, after processing: 2
INFO [runner] Processors filtering stat (out/in): skip_files: 43/43, identifier_marker: 43/43, diff: 2/2, max_same_issues: 2/2, max_from_linter: 2/2, sort_results: 2/2, skip_dirs: 43/43, autogenerated_exclude: 43/43, exclude: 41/43, exclude-rules: 3/41, severity-rules: 2/2, cgo: 43/43, filename_unadjuster: 43/43, uniq_by_line: 2/3, path_prefixer: 2/2, path_prettifier: 43/43, nolint: 3/3, max_per_file_from_linter: 2/2, source_code: 2/2, path_shortener: 2/2
INFO [runner] processing took 1.364588ms with stages: identifier_marker: 378.958µs, autogenerated_exclude: 336.25µs, path_prettifier: 261.75µs, nolint: 110.5µs, exclude: 93.75µs, skip_dirs: 87.667µs, exclude-rules: 65.458µs, source_code: 18.626µs, cgo: 3.792µs, filename_unadjuster: 2µs, uniq_by_line: 1.792µs, max_same_issues: 1.417µs, max_from_linter: 626ns, skip_files: 459ns, path_shortener: 417ns, max_per_file_from_linter: 416ns, severity-rules: 250ns, diff: 209ns, sort_results: 167ns, path_prefixer: 84ns
INFO [runner] linters took 5.119150833s with stages: goanalysis_metalinter: 5.11773975s, structcheck: 5.167µs
provider/cache.go:31:2: field `g` is unused (unused)
	g       func() (T, error)
	^
provider/cache.go:32:2: field `val` is unused (unused)
	val     T
	^
INFO File cache stats: 1 entries of total size 1.6KiB
INFO Memory: 66 samples, avg is 670.9MB, max is 941.6MB
INFO Execution took 6.41705175s
exit status 1

Code example or link to a public repository

evcc-io/evcc@bc4545e

@andig andig added the bug Something isn't working label Apr 17, 2022
@andig andig mentioned this issue Apr 17, 2022
13 tasks
@ldez
Copy link
Member

ldez commented Apr 17, 2022

Hello,
Have you checked with the binary of staticcheck?

@andig
Copy link
Author

andig commented Apr 17, 2022

Checked with both master and 0.3.0. Finds other errors but even after fixing not this one. Should I try with any specific params to trigger this?

@andig andig changed the title staticcheck false positive on master unused false positive on master Apr 17, 2022
@ldez
Copy link
Member

ldez commented Apr 17, 2022

I found the problem, I will try to fix it.

@andig
Copy link
Author

andig commented Apr 19, 2022

Confirmed working. No more false positive!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants