fix: add nolint:errcheck comments for intentionally unchecked errors

Add //nolint:errcheck comments to intentionally unchecked error returns:

- defer X.Close() calls: errors from closing read-only resources, rows
  after iteration, files, response bodies, and gzip readers are not
  actionable and don't affect correctness

- defer tx.Rollback(): standard Go pattern where rollback after
  successful commit returns an error, which is expected behavior

- defer stmt.Close(): statements are closed with their transactions

- Cleanup operations: DeleteRevision on failure and os.RemoveAll for
  temp directories are best-effort cleanup

- HTTP response encoding: if JSON encoding fails at response time,
  there's nothing useful we can do

- Test/benchmark code: unchecked errors in test setup/cleanup where
  failures will surface through test assertions

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-04 01:51:20 +01:00
parent 097b661aed
commit ea11dd5e14
14 changed files with 91 additions and 90 deletions

View File

@@ -12,7 +12,7 @@ func BenchmarkCreateOptions(b *testing.B) {
if err != nil {
b.Fatalf("Failed to create store: %v", err)
}
defer store.Close()
defer store.Close() //nolint:errcheck // benchmark cleanup
ctx := context.Background()
if err := store.Initialize(ctx); err != nil {
@@ -53,7 +53,7 @@ func benchmarkBatch(b *testing.B, batchSize int) {
if err != nil {
b.Fatalf("Failed to create store: %v", err)
}
defer store.Close()
defer store.Close() //nolint:errcheck // benchmark cleanup
ctx := context.Background()
if err := store.Initialize(ctx); err != nil {
@@ -88,9 +88,9 @@ func benchmarkBatch(b *testing.B, batchSize int) {
}
// Clean up for next iteration
store.DeleteRevision(ctx, rev.ID)
_ = store.DeleteRevision(ctx, rev.ID) //nolint:errcheck // benchmark cleanup
rev = &Revision{GitHash: fmt.Sprintf("batchbench%d", i), ChannelName: "bench"}
store.CreateRevision(ctx, rev)
_ = store.CreateRevision(ctx, rev) //nolint:errcheck // benchmark setup
for _, opt := range opts {
opt.RevisionID = rev.ID
}
@@ -102,7 +102,7 @@ func BenchmarkSearchOptions(b *testing.B) {
if err != nil {
b.Fatalf("Failed to create store: %v", err)
}
defer store.Close()
defer store.Close() //nolint:errcheck // benchmark cleanup
ctx := context.Background()
if err := store.Initialize(ctx); err != nil {
@@ -144,7 +144,7 @@ func BenchmarkGetChildren(b *testing.B) {
if err != nil {
b.Fatalf("Failed to create store: %v", err)
}
defer store.Close()
defer store.Close() //nolint:errcheck // benchmark cleanup
ctx := context.Background()
if err := store.Initialize(ctx); err != nil {
@@ -197,7 +197,7 @@ func BenchmarkSchemaInitialize(b *testing.B) {
b.Fatalf("Failed to initialize: %v", err)
}
store.Close()
store.Close() //nolint:errcheck // benchmark cleanup
}
}
@@ -207,7 +207,7 @@ func BenchmarkRevisionCRUD(b *testing.B) {
if err != nil {
b.Fatalf("Failed to create store: %v", err)
}
defer store.Close()
defer store.Close() //nolint:errcheck // benchmark cleanup
ctx := context.Background()
if err := store.Initialize(ctx); err != nil {