diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-06-09 16:26:48 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-06-14 08:52:28 +0300 |
commit | ac48a410955889637f1d0fa98ac102ab3b9ea088 (patch) | |
tree | 672b1e482af649518092097df24473d223f869ce | |
parent | cdf1a7d59b84ee1097be4e88df3f885171c028e7 (diff) |
stats: Drop error code of `printInteractive()`
The gitaly-debug executable can be used to clone from a remote
repository and print several statistics about the clone itself, like for
example how long several stages took. Because of this, the stats package
supports an "interactive" flag which causes it to print various events
to stdout: only if it's set to true will `printInteractive()` actually
print anything.
One code smell we have right now is that `printInteractive()` returns an
error, but it's never actually checked. And we probably don't even want
to: it's only used for gitaly-debug to print to stdout, so it's harmless
enough if it would fail.
Get rid of the error code and just ignore when `fmt.Printf()` fails and
remove the golang-ci exemption.
-rw-r--r-- | .golangci.yml | 4 | ||||
-rw-r--r-- | internal/git/stats/analyzehttp.go | 12 |
2 files changed, 5 insertions, 11 deletions
diff --git a/.golangci.yml b/.golangci.yml index 3a4b43bb1..9ed865be8 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -777,10 +777,6 @@ issues: text: "Error return value is not checked" - linters: - errcheck - path: "internal/git/stats/analyzehttp.go" - text: "Error return value of `cl.printInteractive` is not checked" - - linters: - - errcheck path: "internal/supervisor/supervisor_test.go" text: "Error return value of `syscall\\.Kill` is not checked" ## errcheck: Specific issues in *_test.go files diff --git a/internal/git/stats/analyzehttp.go b/internal/git/stats/analyzehttp.go index a4ed522b0..95144afa8 100644 --- a/internal/git/stats/analyzehttp.go +++ b/internal/git/stats/analyzehttp.go @@ -322,16 +322,14 @@ func (cl *Clone) doPost(ctx context.Context) error { return nil } -func (cl *Clone) printInteractive(format string, a ...interface{}) error { +func (cl *Clone) printInteractive(format string, a ...interface{}) { if !cl.Interactive { - return nil + return } - if _, err := fmt.Println(fmt.Sprintf(format, a...)); err != nil { - return err - } - - return nil + // Ignore any errors returned by this given that we only use it as a debugging aid + // to write to stdout. + fmt.Printf(format+"\n", a...) } const ( |