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:
@@ -59,7 +59,7 @@ func TestHTTPTransportInitialize(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Errorf("Expected 200, got %d", resp.StatusCode)
|
||||
@@ -103,7 +103,7 @@ func TestHTTPTransportSessionRequired(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusBadRequest {
|
||||
t.Errorf("Expected 400 without session, got %d", resp.StatusCode)
|
||||
@@ -129,7 +129,7 @@ func TestHTTPTransportInvalidSession(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusNotFound {
|
||||
t.Errorf("Expected 404 for invalid session, got %d", resp.StatusCode)
|
||||
@@ -158,7 +158,7 @@ func TestHTTPTransportValidSession(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Errorf("Expected 200 with valid session, got %d", resp.StatusCode)
|
||||
@@ -185,7 +185,7 @@ func TestHTTPTransportNotificationAccepted(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusAccepted {
|
||||
t.Errorf("Expected 202 for notification, got %d", resp.StatusCode)
|
||||
@@ -210,7 +210,7 @@ func TestHTTPTransportDeleteSession(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusNoContent {
|
||||
t.Errorf("Expected 204 for delete, got %d", resp.StatusCode)
|
||||
@@ -232,7 +232,7 @@ func TestHTTPTransportDeleteNonexistentSession(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusNotFound {
|
||||
t.Errorf("Expected 404 for nonexistent session, got %d", resp.StatusCode)
|
||||
@@ -315,7 +315,7 @@ func TestHTTPTransportOriginValidation(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if tt.expectAllowed && resp.StatusCode == http.StatusForbidden {
|
||||
t.Error("Expected request to be allowed but was forbidden")
|
||||
@@ -340,7 +340,7 @@ func TestHTTPTransportSSERequiresAcceptHeader(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusNotAcceptable {
|
||||
t.Errorf("Expected 406 without Accept header, got %d", resp.StatusCode)
|
||||
@@ -361,7 +361,7 @@ func TestHTTPTransportSSEStream(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("Expected 200, got %d", resp.StatusCode)
|
||||
@@ -425,7 +425,7 @@ func TestHTTPTransportSSEKeepalive(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("Expected 200, got %d", resp.StatusCode)
|
||||
@@ -483,7 +483,7 @@ func TestHTTPTransportParseError(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Errorf("Expected 200 (with JSON-RPC error), got %d", resp.StatusCode)
|
||||
@@ -511,7 +511,7 @@ func TestHTTPTransportMethodNotAllowed(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusMethodNotAllowed {
|
||||
t.Errorf("Expected 405, got %d", resp.StatusCode)
|
||||
@@ -530,7 +530,7 @@ func TestHTTPTransportOptionsRequest(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusNoContent {
|
||||
t.Errorf("Expected 204, got %d", resp.StatusCode)
|
||||
@@ -641,7 +641,7 @@ func TestHTTPTransportRequestBodyTooLarge(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusRequestEntityTooLarge {
|
||||
t.Errorf("Expected 413 for oversized request, got %d", resp.StatusCode)
|
||||
@@ -670,7 +670,7 @@ func TestHTTPTransportSessionLimitReached(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request %d failed: %v", i, err)
|
||||
}
|
||||
resp.Body.Close()
|
||||
resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Errorf("Request %d: expected 200, got %d", i, resp.StatusCode)
|
||||
@@ -685,7 +685,7 @@ func TestHTTPTransportSessionLimitReached(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusServiceUnavailable {
|
||||
t.Errorf("Expected 503 when session limit reached, got %d", resp.StatusCode)
|
||||
@@ -713,7 +713,7 @@ func TestHTTPTransportRequestBodyWithinLimit(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Request failed: %v", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
defer resp.Body.Close() //nolint:errcheck // test cleanup
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Errorf("Expected 200 for valid request within limit, got %d", resp.StatusCode)
|
||||
|
||||
Reference in New Issue
Block a user