typecheck bug report: imported but not used (typecheck) false negative on windows, no error on GNU/Linux #3246
-
Welcome
Description of the problemSteps to reproduce on an
What happens:
What is expected:
Version of golangci-lint$ golangci-lint --version
golangci-lint has version v1.49.1-0.20220925124108-d1dc9ae4fd3d built from (unknown, mod sum: "h1:53JXh+5xcoDh2xvAApLCQGoyHAyrRV2Gg9tEDiAw/Yg=") on (unknown) Configuration file$ cat .golangci.yml
linters:
enable:
- gosimple
- typecheck
- govet
- errcheck
- staticcheck
- unused
- dupl
#- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
- gofmt
- misspell
- gocritic
- bidichk
- ineffassign
- revive
- gofumpt
- depguard
- nakedret
- unconvert
- nolintlint
- stylecheck
enable-all: false
disable-all: true
fast: false
run:
go: 1.19
timeout: 10m
skip-dirs:
- node_modules
- public
- web_src
linters-settings:
stylecheck:
checks: ["all", "-ST1005", "-ST1003"]
nakedret:
max-func-lines: 0
gocritic:
disabled-checks:
- ifElseChain
- singleCaseSwitch # Every time this occurred in the code, there was no other way.
revive:
ignore-generated-header: false
severity: warning
confidence: 0.8
errorCode: 1
warningCode: 1
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: duplicated-imports
- name: modifies-value-receiver
gofumpt:
extra-rules: true
lang-version: "1.19"
depguard:
# TODO: use depguard to replace import checks in gitea-vet
list-type: denylist
# Check the list against standard lib.
include-go-root: true
packages-with-error-message:
- encoding/json: "use gitea's modules/json instead of encoding/json"
- github.com/unknwon/com: "use gitea's util and replacements"
issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
- unparam
- staticcheck
- path: models/migrations/v
linters:
- gocyclo
- errcheck
- dupl
- gosec
- linters:
- dupl
text: "webhook"
- linters:
- gocritic
text: "`ID' should not be capitalized"
- path: modules/templates/helper.go
linters:
- gocritic
- linters:
- unused
- deadcode
text: "swagger"
- path: contrib/pr/checkout.go
linters:
- errcheck
- path: models/issue.go
linters:
- errcheck
- path: models/migrations/
linters:
- errcheck
- path: modules/log/
linters:
- errcheck
- path: routers/api/v1/repo/issue_subscription.go
linters:
- dupl
- path: routers/repo/view.go
linters:
- dupl
- path: models/migrations/
linters:
- unused
- linters:
- staticcheck
text: "argument x is overwritten before first use"
- path: modules/httplib/httplib.go
linters:
- staticcheck
# Enabling this would require refactoring the methods and how they are called.
- path: models/issue_comment_list.go
linters:
- dupl
- linters:
- misspell
text: '`Unknwon` is a misspelling of `Unknown`'
- path: models/update.go
linters:
- unused
- path: cmd/dump.go
linters:
- dupl
- path: services/webhook/webhook.go
linters:
- structcheck
- text: "commentFormatting: put a space between `//` and comment text"
linters:
- gocritic
- text: "exitAfterDefer:"
linters:
- gocritic
- path: modules/graceful/manager_windows.go
linters:
- staticcheck
text: "svc.IsAnInteractiveSession is deprecated: Use IsWindowsService instead."
- path: models/user/openid.go
linters:
- golint
- path: models/user/badge.go
linters:
- revive
text: "exported: type name will be used as user.UserBadge by other packages, and that stutters; consider calling this Badge" Go environment$ go version && go env
go version go1.19.1 linux/amd64
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/earl-warren/.cache/go-build"
GOENV="/home/earl-warren/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.19.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/gitea/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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1304108160=/tmp/go-build -gno-record-gcc-switches"
Verbose output of running$ golangci-lint cache clean
$ golangci-lint run -v
INFO [config_reader] Config search paths: [./ /tmp/gitea /tmp / /home/earl-warren]
INFO [config_reader] Used config file .golangci.yml
INFO [lintersdb] Active 19 linters: [bidichk depguard dupl errcheck gocritic gofmt gofumpt gosimple govet ineffassign misspell nakedret nolintlint revive staticcheck stylecheck typecheck unconvert unused]
INFO [loader] Go packages loading at mode 575 (deps|exports_file|files|name|types_sizes|compiled_files|imports) took 886.94584ms
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 104.903176ms
INFO [linters_context/goanalysis] analyzers took 13m2.31210014s with top 10 stages: buildir: 3m5.208246754s, bidichk: 46.939660042s, the_only_name: 44.283145101s, dupl: 42.208818032s, unconvert: 26.454724163s, gofumpt: 21.525587928s, gocritic: 19.978102845s, S1038: 15.230218394s, gofmt: 12.646047682s, unused: 8.116555332s
INFO [runner/skip_dirs] Skipped 5 issues from dir modules/public by pattern public
INFO [runner] Issues before processing: 3215, after processing: 0
INFO [runner] Processors filtering stat (out/in): identifier_marker: 3181/3181, nolint: 0/24, filename_unadjuster: 3215/3215, path_prettifier: 3215/3215, exclude-rules: 24/3181, skip_dirs: 3210/3215, autogenerated_exclude: 3181/3210, cgo: 3215/3215, skip_files: 3215/3215, exclude: 3181/3181
INFO [runner] processing took 218.370142ms with stages: exclude-rules: 98.338935ms, identifier_marker: 67.850182ms, autogenerated_exclude: 22.324131ms, path_prettifier: 14.728787ms, nolint: 11.616866ms, skip_dirs: 2.980059ms, cgo: 311.824µs, filename_unadjuster: 213.695µs, max_same_issues: 1.765µs, skip_files: 686ns, uniq_by_line: 562ns, exclude: 521ns, diff: 355ns, source_code: 319ns, severity-rules: 277ns, path_shortener: 275ns, max_per_file_from_linter: 266ns, sort_results: 249ns, max_from_linter: 246ns, path_prefixer: 142ns
INFO [runner] linters took 39.090883889s with stages: goanalysis_metalinter: 38.872431192s
INFO File cache stats: 1786 entries of total size 8.9MiB
INFO Memory: 317 samples, avg is 1928.3MB, max is 2442.2MB
INFO Execution took 40.088669098s
$ GOOS=windows GOARCH=amd64 golangci-lint run -v
level=info msg="[config_reader] Config search paths: [./ /tmp/gitea /tmp / /home/earl-warren]"
level=info msg="[config_reader] Used config file .golangci.yml"
level=info msg="[lintersdb] Active 19 linters: [bidichk depguard dupl errcheck gocritic gofmt gofumpt gosimple govet ineffassign misspell nakedret nolintlint revive staticcheck stylecheck typecheck unconvert unused]"
level=info msg="[loader] Go packages loading at mode 575 (name|compiled_files|exports_file|files|types_sizes|deps|imports) took 913.072764ms"
level=info msg="[runner/filename_unadjuster] Pre-built 0 adjustments in 99.937877ms"
level=info msg="[linters_context/goanalysis] analyzers took 9m49.385528409s with top 10 stages: buildir: 3m5.698038229s, dupl: 40.195382158s, bidichk: 38.091745563s, the_only_name: 36.829165879s, unconvert: 25.867193543s, gofumpt: 19.239727459s, gocritic: 17.911602235s, S1038: 12.618021621s, gofmt: 9.143752773s, misspell: 6.440720529s"
level=info msg="[runner/skip_dirs] Skipped 5 issues from dir modules/public by pattern public"
level=info msg="[runner] Issues before processing: 2953, after processing: 1"
level=info msg="[runner] Processors filtering stat (out/in): cgo: 2953/2953, filename_unadjuster: 2953/2953, nolint: 167/191, diff: 1/1, source_code: 1/1, path_prefixer: 1/1, max_same_issues: 1/1, max_from_linter: 1/1, skip_dirs: 2948/2953, autogenerated_exclude: 2919/2948, identifier_marker: 2919/2919, exclude: 2919/2919, exclude-rules: 191/2919, uniq_by_line: 1/167, path_prettifier: 2953/2953, skip_files: 2953/2953, path_shortener: 1/1, severity-rules: 1/1, sort_results: 1/1, max_per_file_from_linter: 1/1"
level=info msg="[runner] processing took 181.904222ms with stages: exclude-rules: 85.476911ms, identifier_marker: 53.506022ms, autogenerated_exclude: 17.787264ms, path_prettifier: 11.745717ms, nolint: 10.462947ms, skip_dirs: 2.476827ms, cgo: 262.488µs, filename_unadjuster: 149.729µs, source_code: 22.76µs, uniq_by_line: 8.205µs, max_same_issues: 1.277µs, path_shortener: 1.193µs, max_per_file_from_linter: 814ns, exclude: 438ns, skip_files: 402ns, diff: 305ns, max_from_linter: 303ns, severity-rules: 262ns, sort_results: 226ns, path_prefixer: 132ns"
level=info msg="[runner] linters took 37.418867633s with stages: goanalysis_metalinter: 37.236870962s"
services/f3/driver/driver.go:18:2: "lab.forgefriends.org/friendlyforgeformat/gof3/format" imported but not used (typecheck)
"lab.forgefriends.org/friendlyforgeformat/gof3/format"
^
level=info msg="File cache stats: 1589 entries of total size 7.8MiB"
level=info msg="Memory: 316 samples, avg is 1823.6MB, max is 2237.1MB"
level=info msg="Execution took 38.437243532s" Code example or link to a public repositorySee above |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Could you please explain the difference between an issue and a discussion? The intuition suggests discussions are about debatable opinions and issues are about reproducible bugs. This is a reproducible bug and the steps to reproduce it were detailed in the description. What am I not understanding in the bug reporting process? |
Beta Was this translation helpful? Give feedback.
-
Oh. So... typecheck displays an error as a side effect of a compilation failure. dang thanks for articulating it, this conversation can be closed. |
Beta Was this translation helpful? Give feedback.
-
Hello,
|
Beta Was this translation helpful? Give feedback.
Hello,
typecheck
is not a real linter it's just a way to parse/display "compilation" and linters errors (linter reports are not errors).