From 7dad9c7a170aa03d98c9cfc615e4b4d03033f27e Mon Sep 17 00:00:00 2001 From: rcourtman Date: Thu, 27 Nov 2025 09:21:11 +0000 Subject: [PATCH] style: fix additional staticcheck warnings - Lowercase error messages (ST1005) - Use context.Background() instead of nil (SA1012) - Fix rand.Intn(1) which always returns 0 (SA4030) - Remove unnecessary nil check before len() (S1009) --- internal/api/system_settings.go | 8 ++++---- internal/logging/logging_test.go | 2 +- internal/mock/generator.go | 2 +- internal/models/converters_test.go | 2 +- internal/notifications/notifications.go | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/api/system_settings.go b/internal/api/system_settings.go index 219826b..be92cb1 100644 --- a/internal/api/system_settings.go +++ b/internal/api/system_settings.go @@ -171,16 +171,16 @@ func validateSystemSettings(settings *config.SystemSettings, rawRequest map[stri if val, ok := rawRequest["backupPollingInterval"]; ok { if interval, ok := val.(float64); ok { if interval < 0 { - return fmt.Errorf("Backup polling interval cannot be negative") + return fmt.Errorf("backup polling interval cannot be negative") } if interval > 0 && interval < 10 { - return fmt.Errorf("Backup polling interval must be at least 10 seconds") + return fmt.Errorf("backup polling interval must be at least 10 seconds") } if interval > 604800 { - return fmt.Errorf("Backup polling interval cannot exceed 604800 seconds (7 days)") + return fmt.Errorf("backup polling interval cannot exceed 604800 seconds (7 days)") } } else { - return fmt.Errorf("Backup polling interval must be a number") + return fmt.Errorf("backup polling interval must be a number") } } diff --git a/internal/logging/logging_test.go b/internal/logging/logging_test.go index 9d10094..af1ae83 100644 --- a/internal/logging/logging_test.go +++ b/internal/logging/logging_test.go @@ -271,7 +271,7 @@ func TestWithLoggerNilContext(t *testing.T) { Init(Config{}) - ctx := WithLogger(nil, New("svc", WithWriter(io.Discard))) + ctx := WithLogger(context.Background(), New("svc", WithWriter(io.Discard))) if ctx == nil { t.Fatal("expected non-nil context") } diff --git a/internal/mock/generator.go b/internal/mock/generator.go index 4b5d037..5d50cdd 100644 --- a/internal/mock/generator.go +++ b/internal/mock/generator.go @@ -2970,7 +2970,7 @@ func generatePMGInstances() []models.PMGInstance { edgeQueue := &models.PMGQueueStatus{ Active: rand.Intn(2), Deferred: rand.Intn(5), - Hold: rand.Intn(1), + Hold: rand.Intn(2), // rand.Intn(1) always returns 0 Incoming: rand.Intn(3), Total: 0, OldestAge: int64(rand.Intn(600)), diff --git a/internal/models/converters_test.go b/internal/models/converters_test.go index f77e187..fbfdbcf 100644 --- a/internal/models/converters_test.go +++ b/internal/models/converters_test.go @@ -78,7 +78,7 @@ func TestCopyStringFloatMap(t *testing.T) { } // Verify it's a copy, not the same reference - if tc.input != nil && len(tc.input) > 0 { + if len(tc.input) > 0 { for k := range result { result[k] = 999.0 break diff --git a/internal/notifications/notifications.go b/internal/notifications/notifications.go index 87b8b5b..6f639c2 100644 --- a/internal/notifications/notifications.go +++ b/internal/notifications/notifications.go @@ -2305,7 +2305,7 @@ func formatWebhookDuration(d time.Duration) string { // extractTelegramChatID extracts and validates the chat_id from a Telegram webhook URL func extractTelegramChatID(webhookURL string) (string, error) { if !strings.Contains(webhookURL, "chat_id=") { - return "", fmt.Errorf("Telegram webhook URL missing chat_id parameter") + return "", fmt.Errorf("telegram webhook URL missing chat_id parameter") } u, err := url.Parse(webhookURL)