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:
@@ -182,6 +182,7 @@ func (t *HTTPTransport) handlePost(w http.ResponseWriter, r *http.Request) {
|
||||
if err := json.Unmarshal(body, &req); err != nil {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
//nolint:errcheck // response already being written, can't handle encode error
|
||||
json.NewEncoder(w).Encode(Response{
|
||||
JSONRPC: "2.0",
|
||||
Error: &Error{
|
||||
@@ -237,7 +238,7 @@ func (t *HTTPTransport) handlePost(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(resp)
|
||||
_ = json.NewEncoder(w).Encode(resp) //nolint:errcheck // response already being written
|
||||
}
|
||||
|
||||
// handleInitialize handles the initialize request and creates a new session.
|
||||
@@ -271,7 +272,7 @@ func (t *HTTPTransport) handleInitialize(w http.ResponseWriter, r *http.Request,
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.Header().Set("Mcp-Session-Id", session.ID)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
json.NewEncoder(w).Encode(resp)
|
||||
_ = json.NewEncoder(w).Encode(resp) //nolint:errcheck // response already being written
|
||||
}
|
||||
|
||||
// handleGet handles SSE stream for server-initiated notifications.
|
||||
|
||||
Reference in New Issue
Block a user