From bc9e89696bac14826b421269c0033e2377ce62ea Mon Sep 17 00:00:00 2001 From: rcourtman Date: Thu, 27 Nov 2025 09:12:17 +0000 Subject: [PATCH] chore: fix staticcheck U1000 unused code warnings - Remove unused ipv6Regex from validation.go - Suppress unused recordAlertFired/recordAlertResolved hooks (kept for future use) - Remove unused apiLimiter rate limiter - Remove unused stopOnce fields from csrf_store.go and session_store.go - Remove unused lastBroadcast field from hub.go - Remove unused lastUsedIndex field from cluster_client.go --- cmd/pulse-sensor-proxy/validation.go | 3 --- internal/alerts/alerts.go | 5 ++++- internal/api/csrf_store.go | 1 - internal/api/security.go | 3 --- internal/api/session_store.go | 1 - internal/websocket/hub.go | 1 - pkg/proxmox/cluster_client.go | 1 - 7 files changed, 4 insertions(+), 11 deletions(-) diff --git a/cmd/pulse-sensor-proxy/validation.go b/cmd/pulse-sensor-proxy/validation.go index 82926230a..21c180f39 100644 --- a/cmd/pulse-sensor-proxy/validation.go +++ b/cmd/pulse-sensor-proxy/validation.go @@ -23,9 +23,6 @@ var ( // ipv4Regex validates IPv4 addresses ipv4Regex = regexp.MustCompile(`^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$`) - - // ipv6Regex validates IPv6 addresses (simplified) - ipv6Regex = regexp.MustCompile(`^[0-9a-fA-F:]+$`) ) var ( diff --git a/internal/alerts/alerts.go b/internal/alerts/alerts.go index c3248a562..1ddac41ba 100644 --- a/internal/alerts/alerts.go +++ b/internal/alerts/alerts.go @@ -431,12 +431,15 @@ var ( recordAlertAcknowledged func() ) -// SetMetricHooks registers callbacks for recording alert metrics +// SetMetricHooks registers callbacks for recording alert metrics. +// Note: fired and resolved callbacks are stored for future use but not yet wired into alert lifecycle. func SetMetricHooks(fired func(*Alert), resolved func(*Alert), suppressed func(string), acknowledged func()) { recordAlertFired = fired recordAlertResolved = resolved recordAlertSuppressed = suppressed recordAlertAcknowledged = acknowledged + // Silence staticcheck U1000 - hooks are stored for future metric integration + _, _ = recordAlertFired, recordAlertResolved } type Manager struct { diff --git a/internal/api/csrf_store.go b/internal/api/csrf_store.go index b743bc693..082dd0b2c 100644 --- a/internal/api/csrf_store.go +++ b/internal/api/csrf_store.go @@ -29,7 +29,6 @@ type CSRFTokenStore struct { dataPath string saveTicker *time.Ticker stopChan chan bool - stopOnce sync.Once // Ensures Stop() can only close channel once } func csrfSessionKey(sessionID string) string { diff --git a/internal/api/security.go b/internal/api/security.go index c8331bf0f..89f83b2c5 100644 --- a/internal/api/security.go +++ b/internal/api/security.go @@ -123,9 +123,6 @@ func issueNewCSRFCookie(w http.ResponseWriter, r *http.Request, sessionID string var ( // Auth endpoints: 10 attempts per minute authLimiter = NewRateLimiter(10, 1*time.Minute) - - // General API: 500 requests per minute (increased for metadata endpoints) - apiLimiter = NewRateLimiter(500, 1*time.Minute) ) // GetClientIP extracts the client IP from the request diff --git a/internal/api/session_store.go b/internal/api/session_store.go index cb4e5ac6e..f2f35d626 100644 --- a/internal/api/session_store.go +++ b/internal/api/session_store.go @@ -19,7 +19,6 @@ type SessionStore struct { dataPath string saveTicker *time.Ticker stopChan chan bool - stopOnce sync.Once // Ensures Stop() can only close channel once } func sessionHash(token string) string { diff --git a/internal/websocket/hub.go b/internal/websocket/hub.go index ec811985e..4190493da 100644 --- a/internal/websocket/hub.go +++ b/internal/websocket/hub.go @@ -277,7 +277,6 @@ type Hub struct { getState func() interface{} // Function to get current state allowedOrigins []string // Allowed origins for CORS // Broadcast coalescing fields - lastBroadcast time.Time coalesceWindow time.Duration coalescePending *Message coalesceTimer *time.Timer diff --git a/pkg/proxmox/cluster_client.go b/pkg/proxmox/cluster_client.go index 052fc0287..61350f5a1 100644 --- a/pkg/proxmox/cluster_client.go +++ b/pkg/proxmox/cluster_client.go @@ -22,7 +22,6 @@ type ClusterClient struct { nodeHealth map[string]bool // Track node health lastHealthCheck map[string]time.Time // Track last health check time lastError map[string]string // Track last error per endpoint - lastUsedIndex int // For round-robin config ClientConfig // Base config (auth info) rateLimitUntil map[string]time.Time // Cooldown window for rate-limited endpoints }