Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-08-11 09:46:45 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-09-23 10:02:55 +0300
commitc4396bffd02b7e4878c18fce31269134ba518bf1 (patch)
treeb9f451a9c190fe3e146a6b8ae34a654da24d2935
parentb4c1f29c487a41b2e69a31a99f6b0ac462c81ce4 (diff)
golangci-lint: Stop excluding `Close` and `Serve` from errcheck linter
The errcheck linter is tasked with finding cases where we are mistakenly not checking errors returned by a function. While we have it globally enabled, one gap that we currently have is that we exclude all function calls to `Close` and `Serve`. This exception is something we added back when we added this linter to our rules as it has proven to be too much work to fix all violations in the code base. Not checking any such errors may easily hide issues we're not aware of though and is thus bad practice. Convert the blanket-exclude for all functions to instead explicitly exclude all functions that currently violate it. Like this, it becomes a lot more manageable to fix missing error checks one function at a time and makes sure that we don't add new violations to our codebase that are not covered by any of these explicit function excludes.
-rw-r--r--.golangci.yml38
1 files changed, 35 insertions, 3 deletions
diff --git a/.golangci.yml b/.golangci.yml
index 2c667e980..b86dc3e55 100644
--- a/.golangci.yml
+++ b/.golangci.yml
@@ -46,6 +46,41 @@ linters-settings:
include-go-root: true
packages-with-error-message:
- io/ioutil: "ioutil is deprecated starting with Go 1.16"
+ errcheck:
+ # The following are functions for which we are currently not consistently
+ # checking returned errors. This is not intended as a list of known-okay
+ # cases to skip the checks, but rather as a list of things we should
+ # eventually fix.
+ exclude-functions:
+ # Close
+ - (*archive/tar.Writer).Close
+ - (*compress/zlib.Writer).Close
+ - (*database/sql.DB).Close
+ - (*database/sql.Rows).Close
+ - (*github.com/hashicorp/yamux.Session).Close
+ - (*gitlab.com/gitlab-org/gitaly/v15/client.Pool).Close
+ - (*gitlab.com/gitlab-org/gitaly/v15/client.SidechannelWaiter).Close
+ - (*gitlab.com/gitlab-org/gitaly/v15/internal/gitaly/hook.SidechannelWaiter).Close
+ - (*gitlab.com/gitlab-org/gitaly/v15/internal/safe.FileWriter).Close
+ - (*gitlab.com/gitlab-org/gitaly/v15/internal/safe.LockingFileWriter).Close
+ - (*gitlab.com/gitlab-org/gitaly/v15/internal/sidechannel.ServerConn).Close
+ - (*gitlab.com/gitlab-org/gitaly/v15/internal/sidechannel.Waiter).Close
+ - (*gitlab.com/gitlab-org/gitaly/v15/internal/streamcache.pipe).Close
+ - (*gitlab.com/gitlab-org/gitaly/v15/internal/streamcache.pipeReader).Close
+ - (*google.golang.org/grpc.ClientConn).Close
+ - (*google.golang.org/grpc.ServerConn).Close
+ - (*io.PipeReader).Close
+ - (*io.PipeWriter).Close
+ - (*net.UnixConn).Close
+ - (*os.File).Close
+ - (io.Closer).Close
+ - (io/fs.File).Close
+ - (net.Conn).Close
+ - (net.Listener).Close
+ # Serve
+ - (*gitlab.com/gitlab-org/gitaly/v15/internal/praefect.ServerFactory).Serve
+ - (*google.golang.org/grpc.Server).Serve
+ - (*net/http.Server).Serve
forbidigo:
forbid:
# Tests and code which use timing-based setups have repeatedly resulted
@@ -95,9 +130,6 @@ issues:
- forbidigo
# This fine thing excludes all paths which don't end with "_test.go".
path: "^([^_]|_([^t]|t([^e]|e([^s]|s([^t]|t([^\\.]|\\.([^g]|g[^o])))))))*$"
- - linters:
- - errcheck
- text: "Error return value of `[^`]+.(Close|Serve)` is not checked"
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.