diff --git a/storage/history.go b/storage/history.go index 6af14bc..aa65c43 100644 --- a/storage/history.go +++ b/storage/history.go @@ -17,10 +17,10 @@ func (store *redisStore) Success(ctx context.Context) error { } func (store *redisStore) TotalProcessed(ctx context.Context) uint64 { - return uint64(store.rclient.IncrBy(ctx, "processed", 0).Val()) + return uint64(store.rclient.IncrBy(ctx, "processed", 0).Val()) // nolint:gosec } func (store *redisStore) TotalFailures(ctx context.Context) uint64 { - return uint64(store.rclient.IncrBy(ctx, "failures", 0).Val()) + return uint64(store.rclient.IncrBy(ctx, "failures", 0).Val()) // nolint:gosec } func (store *redisStore) Failure(ctx context.Context) error { @@ -57,7 +57,7 @@ func (store *redisStore) History(ctx context.Context, days int, fn func(day stri } for idx := 0; idx < days; idx++ { - fn(daystrs[idx], uint64(procds[idx].Val()), uint64(fails[idx].Val())) + fn(daystrs[idx], uint64(procds[idx].Val()), uint64(fails[idx].Val())) // nolint:gosec } return nil } diff --git a/storage/queue_redis.go b/storage/queue_redis.go index c65856c..b017f31 100644 --- a/storage/queue_redis.go +++ b/storage/queue_redis.go @@ -87,7 +87,7 @@ func (q *redisQueue) init(ctx context.Context) error { } func (q *redisQueue) Size(ctx context.Context) uint64 { - return uint64(q.store.rclient.LLen(ctx, q.name).Val()) + return uint64(q.store.rclient.LLen(ctx, q.name).Val()) // nolint:gosec } func (q *redisQueue) Add(ctx context.Context, job *client.Job) error { diff --git a/storage/redis.go b/storage/redis.go index bbecaef..203f511 100644 --- a/storage/redis.go +++ b/storage/redis.go @@ -97,7 +97,7 @@ func bootRedis(path string, sock string) (func(), error) { conffilename := "/tmp/redis.conf" if _, err := os.Stat(conffilename); err != nil { - if err != nil && os.IsNotExist(err) { + if os.IsNotExist(err) { // nolint:gosec err := os.WriteFile("/tmp/redis.conf", []byte(fmt.Sprintf(redisconf, client.Version)), 0o444) if err != nil { @@ -231,7 +231,7 @@ func openRedis(sock string, poolSize uint64) (Store, error) { Network: "unix", Addr: sock, DB: 0, - PoolSize: int(poolSize), + PoolSize: int(poolSize), // nolint:gosec }) _, err := rclient.Ping(ctx).Result() if err != nil { diff --git a/storage/sorted_redis.go b/storage/sorted_redis.go index c7aabcc..d392ae3 100644 --- a/storage/sorted_redis.go +++ b/storage/sorted_redis.go @@ -31,7 +31,7 @@ func (rs *redisSorted) Name() string { } func (rs *redisSorted) Size(ctx context.Context) uint64 { - return uint64(rs.store.rclient.ZCard(ctx, rs.name).Val()) + return uint64(rs.store.rclient.ZCard(ctx, rs.name).Val()) // nolint:gosec } func (rs *redisSorted) Clear(ctx context.Context) error { diff --git a/test/go_system_test.go b/test/go_system_test.go index 8256bd3..e64caa6 100644 --- a/test/go_system_test.go +++ b/test/go_system_test.go @@ -74,8 +74,8 @@ func TestSystem(t *testing.T) { wg.Wait() bg := context.Background() - assert.EqualValues(t, 3*each, int(s.Store().TotalProcessed(bg))) - assert.EqualValues(t, 3*(each/100), int(s.Store().TotalFailures(bg))) + assert.EqualValues(t, 3*each, s.Store().TotalProcessed(bg)) + assert.EqualValues(t, 3*(each/100), s.Store().TotalFailures(bg)) s.Stop(nil) } diff --git a/webui/helpers.go b/webui/helpers.go index f6dcf55..e56710f 100644 --- a/webui/helpers.go +++ b/webui/helpers.go @@ -67,7 +67,7 @@ func t(req *http.Request, word string) string { return dc.Translation(word) } -func pageparam(req *http.Request, pageValue uint64) string { +func pageparam(_ *http.Request, pageValue uint64) string { return fmt.Sprintf("page=%d", pageValue) } @@ -141,7 +141,7 @@ func uintWithDelimiter(val uint64) string { func queueJobs(r *http.Request, q storage.Queue, count, currentPage uint64, fn func(idx int, key []byte, job *client.Job)) { c := r.Context() - err := q.Page(c, int64((currentPage-1)*count), int64(count), func(idx int, data []byte) error { + err := q.Page(c, int64((currentPage-1)*count), int64(count), func(idx int, data []byte) error { // nolint:gosec var job client.Job err := util.JsonUnmarshal(data, &job) if err != nil { @@ -177,13 +177,13 @@ func unfiltered() bool { return true } -func filtering(set string) string { +func filtering(_ string) string { return "" } func setJobs(req *http.Request, set storage.SortedSet, count, currentPage uint64, fn func(idx int, key []byte, job *client.Job)) { c := req.Context() - _, err := set.Page(c, int((currentPage-1)*count), int(count), func(idx int, entry storage.SortedEntry) error { + _, err := set.Page(c, int((currentPage-1)*count), int(count), func(idx int, entry storage.SortedEntry) error { // nolint:gosec job, err := entry.Job() if err != nil { util.Warnf("Error parsing JSON: %s", string(entry.Value())) @@ -464,7 +464,7 @@ func displayLimitedArgs(args []interface{}, limit int) string { s = data.String() } if len(s) > limit { - fmt.Fprintf(&b, s[0:limit]) + fmt.Fprintf(&b, "%s", s[0:limit]) b.WriteRune('…') } else { fmt.Fprint(&b, s) diff --git a/webui/pages.go b/webui/pages.go index 586542b..54482e5 100644 --- a/webui/pages.go +++ b/webui/pages.go @@ -117,11 +117,11 @@ func queueHandler(w http.ResponseWriter, r *http.Request) { p := r.URL.Query()["page"] if p != nil { val, err := strconv.Atoi(p[0]) - if err != nil { + if err != nil || val < 0 { http.Error(w, "Invalid parameter", http.StatusBadRequest) return } - currentPage = uint64(val) + currentPage = uint64(val) // nolint:gosec } count := uint64(25) @@ -147,11 +147,11 @@ func retriesHandler(w http.ResponseWriter, r *http.Request) { p := r.URL.Query()["page"] if p != nil { val, err := strconv.Atoi(p[0]) - if err != nil { + if err != nil || val < 0 { http.Error(w, "Invalid parameter", http.StatusBadRequest) return } - currentPage = uint64(val) + currentPage = uint64(val) // nolint:gosec } count := uint64(25) @@ -228,11 +228,11 @@ func scheduledHandler(w http.ResponseWriter, r *http.Request) { p := r.URL.Query()["page"] if p != nil { val, err := strconv.Atoi(p[0]) - if err != nil { + if err != nil || val < 0 { http.Error(w, "Invalid parameter", http.StatusBadRequest) return } - currentPage = uint64(val) + currentPage = uint64(val) // nolint:gosec } count := uint64(25) @@ -305,11 +305,11 @@ func morgueHandler(w http.ResponseWriter, r *http.Request) { p := r.URL.Query()["page"] if p != nil { val, err := strconv.Atoi(p[0]) - if err != nil { + if err != nil || val < 0 { http.Error(w, "Invalid parameter", http.StatusBadRequest) return } - currentPage = uint64(val) + currentPage = uint64(val) // nolint:gosec } count := uint64(25)