-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Errcheck not excluding functions as expected when used by Golangci-lint #656
Comments
I cloned
Might be that |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm on golangci-lint v1.39.0 and this appears to still be a problem. As in the original post, |
@Zeplar could you provide an example? Thank you. |
still an issue in
https://github.com/na4ma4/golangci-lint-errcheck-test with .golangci.yml using: linters:
enable:
- errcheck
issues:
exclude-use-default: false
linters-settings:
errcheck:
# exclude: errcheck-exclude.txt
exclude-functions:
- (io.Closer).Close
$ artifacts/bin/v1.41.1/golangci-lint run --sort-results --max-same-issues 0 --max-issues-per-linter 0 ./... | tee "artifacts/lint/golangci-lint"
cmd/errcheck-test/main.go:23:23: Error return value of `resp.Body.Close` is not checked (errcheck)
defer resp.Body.Close()
^ Using $ cat "errcheck-exclude.txt"
(io.Closer).Close $ artifacts/bin/errcheck -verbose ./...
checking github.com/na4ma4/golangci-lint-errcheck-test/cmd/errcheck-test
cmd/errcheck-test/main.go:23:23: (io.Closer).Close defer resp.Body.Close() $ artifacts/bin/errcheck -verbose -exclude errcheck-exclude.txt ./...
checking github.com/na4ma4/golangci-lint-errcheck-test/cmd/errcheck-test this is suppressed by the default exclude:
|
|
I seem to be doing something wrong. I created a folder with two files: package okhandler
import "net/http"
func OkHandler(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("OK"))
} And linters:
enable:
- errcheck
errcheck:
exclude-functions:
- (http.ResponseWriter).Write I run
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I found the root cause, it's a wrong configuration: you have to set the right package linters:
enable:
- errcheck
linters-settings:
errcheck:
exclude-functions:
- (net/http.ResponseWriter).Write |
I am having trouble getting Errcheck to not check methods that are supposedly excluded by default.
Specifically the Hash.Write method explicitly excluded here: https://github.com/kisielk/errcheck/blob/master/internal/errcheck/errcheck.go#L159
If I run Errcheck by itself it does not throw an error in this line, but with Golangci-lint it does, even if I add an explicit exclude file. I don't know what I'm missing here, so any suggestions or troubleshooting steps welcome!
Version:
Golangci-lint Config file:
Errcheck exlude config:
Go version:
go version go1.12.5 linux/amd64
Golangci-lint output:
The text was updated successfully, but these errors were encountered: