You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
errcheck does not report any problem related to any call to the Close method, despite having an appropriate configuration. I have a use case where those errors are significant and must be detected and handled.
When I run errcheck -blank -asserts ./... (latest version of this repository) manually without golangci-lint, I get the expected issues reported:
$ go version && go envgo version go1.21.3 linux/amd64GO111MODULE=''GOARCH='amd64'GOBIN=''GOCACHE='/home/sebastien/.cache/go-build'GOENV='/home/sebastien/.config/go/env'GOEXE=''GOEXPERIMENT=''GOFLAGS=''GOHOSTARCH='amd64'GOHOSTOS='linux'GOINSECURE=''GOMODCACHE='/home/sebastien/go/pkg/mod'GONOPROXY=''GONOSUMDB=''GOOS='linux'GOPATH='/home/sebastien/go'GOPRIVATE=''GOPROXY='https://proxy.golang.org,direct'GOROOT='/usr/lib/go-1.21'GOSUMDB='sum.golang.org'GOTMPDIR=''GOTOOLCHAIN='auto'GOTOOLDIR='/usr/lib/go-1.21/pkg/tool/linux_amd64'GOVCS=''GOVERSION='go1.21.3'GCCGO='gccgo'GOAMD64='v1'AR='ar'CC='gcc'CXX='g++'CGO_ENABLED='1'GOMOD='/home/sebastien/Programmation/astral-divide/go.mod'GOWORK=''CGO_CFLAGS='-O2 -g'CGO_CPPFLAGS=''CGO_CXXFLAGS='-O2 -g'CGO_FFLAGS='-O2 -g'CGO_LDFLAGS='-O2 -g'PKG_CONFIG='pkg-config'GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2728494281=/tmp/go-build -gno-record-gcc-switches'
Verbose output of running
$ golangci-lint cache clean
$ golangci-lint run -vINFO [config_reader] Config search paths: [./ /[redacted path to project] /[redacted path to parent dir of the project] /[redacted path to home] /home /] INFO [config_reader] Used config file .golangci.yml INFO [lintersdb] Active 1 linters: [errcheck] INFO [loader] Go packages loading at mode 575 (types_sizes|exports_file|files|imports|compiled_files|deps|name) took 432.683742ms INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 9.728706ms INFO [linters_context/goanalysis] analyzers took 17.777243ms with top 10 stages: errcheck: 17.58221ms, typecheck: 195.033µs INFO [runner] Issues before processing: 41, after processing: 1 INFO [runner] Processors filtering stat (out/in): diff: 1/1, max_same_issues: 1/1, path_shortener: 1/1, path_prettifier: 41/41, skip_dirs: 41/41, identifier_marker: 41/41, max_per_file_from_linter: 1/1, max_from_linter: 1/1, severity-rules: 1/1, fixer: 1/1, sort_results: 1/1, cgo: 41/41, filename_unadjuster: 41/41, skip_files: 41/41, nolint: 1/1, source_code: 1/1, uniq_by_line: 1/1, path_prefixer: 1/1, autogenerated_exclude: 41/41, exclude: 41/41, exclude-rules: 1/41 INFO [runner] processing took 1.333199ms with stages: path_prettifier: 374.815µs, identifier_marker: 328.037µs, autogenerated_exclude: 224.271µs, nolint: 216.868µs, skip_dirs: 89.639µs, exclude-rules: 60.534µs, source_code: 29.686µs, cgo: 2.645µs, max_same_issues: 1.413µs, path_shortener: 1.122µs, uniq_by_line: 982ns, filename_unadjuster: 881ns, max_from_linter: 712ns, fixer: 290ns, max_per_file_from_linter: 271ns, skip_files: 271ns, exclude: 201ns, severity-rules: 190ns, diff: 161ns, sort_results: 140ns, path_prefixer: 70ns INFO [runner] linters took 149.488983ms with stages: goanalysis_metalinter: 148.101482ms cmd/main.go:34:5: Error return value of `os.Create` is not checked (errcheck) _, _ = os.Create("bar") ^INFO File cache stats: 1 entries of total size 10.1KiB INFO Memory: 7 samples, avg is 40.8MB, max is 98.6MB INFO Execution took 595.449448ms
A minimal reproducible example or link to a public repository
file, err:=os.Create("foo")
iferr!=nil {
panic(err)
}
// I expect an error for each case belowdeferfile.Close()
file.Close()
_=file.Close()
_, _=os.Create("bar") // I only get an error here
Validation
Yes, I've included all information above (version, config, etc.).
The text was updated successfully, but these errors were encountered:
This report is ignored by default, this is the exclusion rule EXC0001.
It was flagged as "Almost all programs ignore errors on these functions and in most cases it's ok".
To show the report, you have to disable the default exclusions:
issues:
exclude-use-default: false
or you have to disable this specific exclusion rule:
Welcome
Description of the problem
errcheck
does not report any problem related to any call to theClose
method, despite having an appropriate configuration. I have a use case where those errors are significant and must be detected and handled.When I run
errcheck -blank -asserts ./...
(latest version of this repository) manually withoutgolangci-lint
, I get the expected issues reported:When I do the same thing via
golangci-lint
, I don't get the expected errors, only the last one:Version of golangci-lint
Configuration
Go environment
Verbose output of running
A minimal reproducible example or link to a public repository
Validation
The text was updated successfully, but these errors were encountered: