fix: resolve golangci-lint violations (errcheck, unused, gosimple, ineffassign)

errcheck: add proper error handling with slog.Error for tx.Rollback, key generation, and s3/dav operations. Add nolint comments for intentionally discarded DB scan errors and HTTP write errors.
unused: remove dead code (svcRow type, processImage, nonDepositPaymentType, generateSecureCode, colorBold, nGreen, nRed)
gosimple S1021: merge var declaration with assignment in manage.go
ineffassign: remove dead assignments in settings.go, till.go, images.go

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-07-09 18:53:51 +01:00
co-authored by Sisyphus
parent b26bf14419
commit ed9cb1489c
34 changed files with 766 additions and 345 deletions
+18 -5
View File
@@ -5,6 +5,7 @@ import (
"crussell/internal/validators"
"database/sql"
"encoding/json"
"log/slog"
"net/http"
"strconv"
@@ -73,7 +74,7 @@ func GetPatchTests(w http.ResponseWriter, r *http.Request) {
return
}
json.NewEncoder(w).Encode(patchTests)
_ = json.NewEncoder(w).Encode(patchTests)
}
// CreatePatchTest handles POST /api/admin/patch-tests
@@ -100,7 +101,11 @@ func CreatePatchTest(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Internal server error", http.StatusInternalServerError)
return
}
defer tx.Rollback(r.Context())
defer func() {
if err := tx.Rollback(r.Context()); err != nil {
slog.Error("failed to rollback transaction", "err", err)
}
}()
var id string
err = tx.QueryRow(r.Context(), query, req.Name, req.Description, req.NoticeDurationHours, req.ExpiryMonths, req.ServiceIDs).Scan(&id)
@@ -115,7 +120,7 @@ func CreatePatchTest(w http.ResponseWriter, r *http.Request) {
}
w.WriteHeader(http.StatusCreated)
json.NewEncoder(w).Encode(map[string]string{"id": id})
_ = json.NewEncoder(w).Encode(map[string]string{"id": id})
}
// UpdatePatchTest handles PUT /api/admin/patch-tests/{id}
@@ -176,7 +181,11 @@ func UpdatePatchTest(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Internal server error", http.StatusInternalServerError)
return
}
defer tx.Rollback(r.Context())
defer func() {
if err := tx.Rollback(r.Context()); err != nil {
slog.Error("failed to rollback transaction", "err", err)
}
}()
_, err = tx.Exec(r.Context(), query, args...)
if err != nil {
@@ -205,7 +214,11 @@ func DeletePatchTest(w http.ResponseWriter, r *http.Request) {
http.Error(w, "Internal server error", http.StatusInternalServerError)
return
}
defer tx.Rollback(r.Context())
defer func() {
if err := tx.Rollback(r.Context()); err != nil {
slog.Error("failed to rollback transaction", "err", err)
}
}()
_, err = tx.Exec(r.Context(), "DELETE FROM patch_tests WHERE id = $1", id)
if err != nil {