From f8a57b3e6b24e0493c51da0c44314965eed73f87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesko=20Ansch=C3=BCtz?= Date: Sun, 22 Mar 2026 17:56:56 +0100 Subject: [PATCH] Bereinige signalstarke Linter-Funde Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- player/agent/internal/app/app_test.go | 2 +- player/agent/internal/statusreporter/reporter.go | 10 +++++++--- server/backend/internal/httpapi/errors.go | 6 +++++- server/backend/internal/httpapi/meta.go | 2 +- server/backend/internal/httpapi/router.go | 4 ++-- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/player/agent/internal/app/app_test.go b/player/agent/internal/app/app_test.go index 6fbf8b5..c375815 100644 --- a/player/agent/internal/app/app_test.go +++ b/player/agent/internal/app/app_test.go @@ -17,7 +17,7 @@ type recordingReporter struct { err error } -func (r *recordingReporter) Send(ctx context.Context, snapshot statusreporter.Snapshot) error { +func (r *recordingReporter) Send(_ context.Context, _ statusreporter.Snapshot) error { r.callCount++ return r.err } diff --git a/player/agent/internal/statusreporter/reporter.go b/player/agent/internal/statusreporter/reporter.go index 1a1d68d..76741f9 100644 --- a/player/agent/internal/statusreporter/reporter.go +++ b/player/agent/internal/statusreporter/reporter.go @@ -70,10 +70,14 @@ func (r *Reporter) Send(ctx context.Context, snapshot Snapshot) error { if err != nil { return fmt.Errorf("send status request: %w", err) } - defer resp.Body.Close() + statusCode := resp.StatusCode + statusText := resp.Status + if err := resp.Body.Close(); err != nil { + return fmt.Errorf("close status response body: %w", err) + } - if resp.StatusCode != http.StatusOK { - return fmt.Errorf("unexpected status response: %s", resp.Status) + if statusCode != http.StatusOK { + return fmt.Errorf("unexpected status response: %s", statusText) } return nil diff --git a/server/backend/internal/httpapi/errors.go b/server/backend/internal/httpapi/errors.go index 7cf4adf..b172269 100644 --- a/server/backend/internal/httpapi/errors.go +++ b/server/backend/internal/httpapi/errors.go @@ -26,6 +26,10 @@ func writeError(w http.ResponseWriter, status int, code, message string, details } func decodeJSON(r *http.Request, dest any) error { - defer r.Body.Close() + defer func() { + if err := r.Body.Close(); err != nil { + return + } + }() return json.NewDecoder(r.Body).Decode(dest) } diff --git a/server/backend/internal/httpapi/meta.go b/server/backend/internal/httpapi/meta.go index a147cb1..7a95a5f 100644 --- a/server/backend/internal/httpapi/meta.go +++ b/server/backend/internal/httpapi/meta.go @@ -2,7 +2,7 @@ package httpapi import "net/http" -func handleMeta(w http.ResponseWriter, r *http.Request) { +func handleMeta(w http.ResponseWriter, _ *http.Request) { writeJSON(w, http.StatusOK, map[string]any{ "service": "morz-infoboard-backend", "version": "dev", diff --git a/server/backend/internal/httpapi/router.go b/server/backend/internal/httpapi/router.go index b52f163..6e63676 100644 --- a/server/backend/internal/httpapi/router.go +++ b/server/backend/internal/httpapi/router.go @@ -7,14 +7,14 @@ import ( func NewRouter() http.Handler { mux := http.NewServeMux() - mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("GET /healthz", func(w http.ResponseWriter, _ *http.Request) { writeJSON(w, http.StatusOK, map[string]string{ "status": "ok", "service": "morz-infoboard-backend", }) }) - mux.HandleFunc("GET /api/v1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("GET /api/v1", func(w http.ResponseWriter, _ *http.Request) { writeJSON(w, http.StatusOK, map[string]any{ "name": "morz-infoboard-backend", "version": "dev",