fix(lint): clear the staticcheck findings

Drop the RealIP middleware: the worker listens on 127.0.0.1 only, and RealIP is deprecated because a client can set its own address. Log the restart error directly, since Restart only returns on failure. Remove an unused slice in a test and pass a real context instead of nil. staticcheck now reports nothing.
This commit is contained in:
2026-10-03 05:00:27 +01:00
parent daa9959961
commit 9d7959f98f
4 changed files with 8 additions and 12 deletions
+1 -3
View File
@@ -500,15 +500,13 @@ func TestObservationStore_CleanupOldObservations(t *testing.T) {
// Store observations beyond the limit WITHOUT async cleanup // Store observations beyond the limit WITHOUT async cleanup
// We disable async cleanup by not setting cleanupFunc // We disable async cleanup by not setting cleanupFunc
var allIDs []int64
for i := 0; i < 105; i++ { for i := 0; i < 105; i++ {
observation := &models.ParsedObservation{ observation := &models.ParsedObservation{
Type: models.ObsTypeDiscovery, Type: models.ObsTypeDiscovery,
Title: "Observation", Title: "Observation",
} }
id, _, err := observationStore.StoreObservation(ctx, "claude-1", "test-project", observation, i, 10) _, _, err := observationStore.StoreObservation(ctx, "claude-1", "test-project", observation, i, 10)
require.NoError(t, err) require.NoError(t, err)
allIDs = append(allIDs, id)
time.Sleep(2 * time.Millisecond) // Ensure different timestamps time.Sleep(2 * time.Millisecond) // Ensure different timestamps
} }
+4 -6
View File
@@ -218,9 +218,8 @@ func (s *Service) handleUpdateRestart(w http.ResponseWriter, r *http.Request) {
// Restart in background after response is sent // Restart in background after response is sent
go func() { go func() {
if err := s.updater.Restart(); err != nil { // Restart only returns when the new worker failed to start.
log.Error().Err(err).Msg("Failed to restart worker") log.Error().Err(s.updater.Restart()).Msg("Failed to restart worker")
}
}() }()
} }
@@ -244,8 +243,7 @@ func (s *Service) handleRestart(w http.ResponseWriter, r *http.Request) {
go func() { go func() {
// Small delay to ensure response is sent // Small delay to ensure response is sent
time.Sleep(100 * time.Millisecond) time.Sleep(100 * time.Millisecond)
if err := s.updater.Restart(); err != nil { // Restart only returns when the new worker failed to start.
log.Error().Err(err).Msg("Failed to restart worker") log.Error().Err(s.updater.Restart()).Msg("Failed to restart worker")
}
}() }()
} }
+3 -2
View File
@@ -1,6 +1,7 @@
package sdk package sdk
import ( import (
"context"
"testing" "testing"
"github.com/lukaszraczylo/claude-mnemonic/internal/vector/sqlitevec" "github.com/lukaszraczylo/claude-mnemonic/internal/vector/sqlitevec"
@@ -121,7 +122,7 @@ func TestCheckVectorDeduplication_NilClient(t *testing.T) {
Narrative: "Some narrative text", Narrative: "Some narrative text",
} }
result := p.checkVectorDeduplication(nil, obs, "test-project") result := p.checkVectorDeduplication(context.Background(), obs, "test-project")
if result.Action != "insert" { if result.Action != "insert" {
t.Errorf("expected Action='insert' when vectorClient is nil, got %q", result.Action) t.Errorf("expected Action='insert' when vectorClient is nil, got %q", result.Action)
} }
@@ -136,7 +137,7 @@ func TestCheckVectorDeduplication_EmptySearchText(t *testing.T) {
// All empty fields // All empty fields
} }
result := p.checkVectorDeduplication(nil, obs, "test-project") result := p.checkVectorDeduplication(context.Background(), obs, "test-project")
if result.Action != "insert" { if result.Action != "insert" {
t.Errorf("expected Action='insert' for empty observation, got %q", result.Action) t.Errorf("expected Action='insert' for empty observation, got %q", result.Action)
} }
-1
View File
@@ -1213,7 +1213,6 @@ func (s *Service) setupMiddleware() {
s.router.Use(middleware.Logger) s.router.Use(middleware.Logger)
s.router.Use(middleware.Recoverer) s.router.Use(middleware.Recoverer)
s.router.Use(middleware.RealIP)
// Add security headers (X-Frame-Options, X-Content-Type-Options, CSP, etc.) // Add security headers (X-Frame-Options, X-Content-Type-Options, CSP, etc.)
s.router.Use(SecurityHeaders) s.router.Use(SecurityHeaders)