From 8b011893276e357181c65c4c6dd095228e92a49b Mon Sep 17 00:00:00 2001 From: SuperQ Date: Mon, 3 Apr 2023 09:05:10 +0200 Subject: [PATCH] Move errcheck excludes config Eliminate the need for a second config file for golangci-lint config file by moving the list of errcheck exclude functions into the yaml config. Signed-off-by: SuperQ --- .github/workflows/ci.yml | 1 + .golangci.yml | 13 ++++++++++++- scripts/errcheck_excludes.txt | 13 ------------- 3 files changed, 13 insertions(+), 14 deletions(-) delete mode 100644 scripts/errcheck_excludes.txt diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ceb374c8c5..1e625b63be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ name: CI on: pull_request: push: + jobs: test_go: name: Go tests diff --git a/.golangci.yml b/.golangci.yml index 81790e6e3a..efa6b2044d 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -33,7 +33,18 @@ linters-settings: - io/ioutil: "Use corresponding 'os' or 'io' functions instead." - regexp: "Use github.com/grafana/regexp instead of regexp" errcheck: - exclude: scripts/errcheck_excludes.txt + exclude-functions: + # Don't flag lines such as "io.Copy(io.Discard, resp.Body)". + - io.Copy + # The next two are used in HTTP handlers, any error is handled by the server itself. + - io.WriteString + - (net/http.ResponseWriter).Write + # No need to check for errors on server's shutdown. + - (*net/http.Server).Shutdown + # Never check for logger errors. + - (github.com/go-kit/log.Logger).Log + # Never check for rollback errors as Rollback() is called when a previous error was detected. + - (github.com/prometheus/prometheus/storage.Appender).Rollback goimports: local-prefixes: github.com/prometheus/prometheus gofumpt: diff --git a/scripts/errcheck_excludes.txt b/scripts/errcheck_excludes.txt deleted file mode 100644 index 8c77ca148d..0000000000 --- a/scripts/errcheck_excludes.txt +++ /dev/null @@ -1,13 +0,0 @@ -// Don't flag lines such as "io.Copy(io.Discard, resp.Body)". -io.Copy -// The next two are used in HTTP handlers, any error is handled by the server itself. -io.WriteString -(net/http.ResponseWriter).Write -// No need to check for errors on server's shutdown. -(*net/http.Server).Shutdown - -// Never check for logger errors. -(github.com/go-kit/log.Logger).Log - -// Never check for rollback errors as Rollback() is called when a previous error was detected. -(github.com/prometheus/prometheus/storage.Appender).Rollback