Skip to content

Commit b29ff4d

Browse files
fix: resolve golangci-lint findings (errcheck 3, staticcheck 2)
- r2.go: explicitly ignore deferred resp.Body.Close() errors (3x errcheck) - handler_test.go: use typed nil context var to preserve the intentional nil-tolerance test while satisfying SA1012 - checks_test.go: convert fakePinger to fakeResult instead of struct literal (S1016) Mechanical lint fixes only — no behavior change. golangci-lint clean, go build/vet/test -short all green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent a7032e7 commit b29ff4d

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

logctx/handler_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ func TestHandler_NilCtx(t *testing.T) {
119119
}
120120
}()
121121
// Pass an explicitly nil context. The handler must treat it as empty.
122-
if err := h.Handle(nil, newRecord("hello")); err != nil {
122+
// Use a typed nil var (not a literal nil) so SA1012 doesn't flag this
123+
// intentional nil-tolerance test.
124+
var nilCtx context.Context
125+
if err := h.Handle(nilCtx, newRecord("hello")); err != nil {
123126
t.Fatalf("Handle: %v", err)
124127
}
125128
rec := decode(t, buf)

readiness/checks_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func TestMustDuration(t *testing.T) {
163163

164164
type fakePinger struct{ err error }
165165

166-
func (f fakePinger) Ping(ctx context.Context) readiness.PingResult { return fakeResult{f.err} }
166+
func (f fakePinger) Ping(ctx context.Context) readiness.PingResult { return fakeResult(f) }
167167

168168
type fakeResult struct{ err error }
169169

storageprovider/r2/r2.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func (p *Provider) issueLongLivedKey(ctx context.Context, in storageprovider.Iss
223223
if err != nil {
224224
return nil, fmt.Errorf("r2.issueLongLivedKey: do request: %w", err)
225225
}
226-
defer resp.Body.Close()
226+
defer func() { _ = resp.Body.Close() }()
227227
respBody, _ := io.ReadAll(resp.Body)
228228
if resp.StatusCode >= 400 {
229229
return nil, fmt.Errorf("r2.issueLongLivedKey: %d: %s", resp.StatusCode, string(respBody))
@@ -284,7 +284,7 @@ func (p *Provider) issueTempCreds(ctx context.Context, in storageprovider.IssueR
284284
if err != nil {
285285
return nil, fmt.Errorf("r2.issueTempCreds: do request: %w", err)
286286
}
287-
defer resp.Body.Close()
287+
defer func() { _ = resp.Body.Close() }()
288288
respBody, _ := io.ReadAll(resp.Body)
289289
if resp.StatusCode >= 400 {
290290
return nil, fmt.Errorf("r2.issueTempCreds: %d: %s", resp.StatusCode, string(respBody))
@@ -343,7 +343,7 @@ func (p *Provider) RevokeTenantCredentials(ctx context.Context, keyID string) er
343343
if err != nil {
344344
return fmt.Errorf("r2.RevokeTenantCredentials: do request: %w", err)
345345
}
346-
defer resp.Body.Close()
346+
defer func() { _ = resp.Body.Close() }()
347347
if resp.StatusCode == http.StatusNotFound {
348348
// Key already gone — idempotent.
349349
return nil

0 commit comments

Comments
 (0)