Lint: Fix linter errors

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2024-08-27 18:58:46 +02:00
parent 8e79d09d5f
commit 368c936c32
Signed by: luzifer
SSH Key Fingerprint: SHA256:/xtE5lCgiRDQr8SLxHMS92ZBlACmATUmF1crK16Ks4E
6 changed files with 10 additions and 11 deletions

2
api.go
View File

@ -136,7 +136,7 @@ func handleCatalogGetVersion(w http.ResponseWriter, r *http.Request) {
} }
w.Header().Set("Content-Type", "text/plain") w.Header().Set("Content-Type", "text/plain")
fmt.Fprint(w, cm.CurrentVersion) fmt.Fprint(w, cm.CurrentVersion) //nolint:errcheck
} }
func handleCatalogList(w http.ResponseWriter, _ *http.Request) { func handleCatalogList(w http.ResponseWriter, _ *http.Request) {

View File

@ -46,7 +46,7 @@ func Create(title, text, color string) []byte {
titleW, _ := calculateTextWidth(title) titleW, _ := calculateTextWidth(title)
textW, _ := calculateTextWidth(text) textW, _ := calculateTextWidth(text)
width := titleW + textW + 4*xSpacing //nolint:gomnd width := titleW + textW + 4*xSpacing //nolint:mnd
t, _ := assets.ReadFile("badge.svg.tpl") t, _ := assets.ReadFile("badge.svg.tpl")
tpl, _ := template.New("svg").Parse(string(t)) tpl, _ := template.New("svg").Parse(string(t))

View File

@ -118,4 +118,6 @@ func (c Client) initDB() error {
return nil return nil
} }
func (l logwrap) Printf(f string, v ...interface{}) { fmt.Fprintf(l.l, f, v...) } func (l logwrap) Printf(f string, v ...interface{}) {
fmt.Fprintf(l.l, f, v...) //nolint:errcheck
}

View File

@ -53,7 +53,7 @@ func (HTMLFetcher) FetchVersion(_ context.Context, attrs *fieldcollection.FieldC
} }
match := regexp.MustCompile(attrs.MustString("regex", &htmlFetcherDefaultRegex)).FindStringSubmatch(node.Data) match := regexp.MustCompile(attrs.MustString("regex", &htmlFetcherDefaultRegex)).FindStringSubmatch(node.Data)
if len(match) < 2 { //nolint:gomnd // Simple count of fields, no need for constant if len(match) < 2 { //nolint:mnd // Simple count of fields, no need for constant
return "", time.Time{}, errors.New("regular expression did not yield version") return "", time.Time{}, errors.New("regular expression did not yield version")
} }

View File

@ -97,7 +97,7 @@ func (JSONFetcher) FetchVersion(ctx context.Context, attrs *fieldcollection.Fiel
} }
match := regexp.MustCompile(attrs.MustString("regex", &jsonFetcherDefaultRegex)).FindStringSubmatch(node.Data) match := regexp.MustCompile(attrs.MustString("regex", &jsonFetcherDefaultRegex)).FindStringSubmatch(node.Data)
if len(match) < 2 { //nolint:gomnd // Simple count of fields, no need for constant if len(match) < 2 { //nolint:mnd // Simple count of fields, no need for constant
return "", time.Time{}, errors.New("regular expression did not yield version") return "", time.Time{}, errors.New("regular expression did not yield version")
} }

View File

@ -3,7 +3,6 @@ package main
import ( import (
"context" "context"
"crypto/md5" //#nosec G501 // Used to derive a static jitter checksum, not cryptographically "crypto/md5" //#nosec G501 // Used to derive a static jitter checksum, not cryptographically
"fmt"
"math" "math"
"strings" "strings"
"time" "time"
@ -120,12 +119,10 @@ func nextCheckTime(ce *database.CatalogEntry, lastCheck *time.Time) time.Time {
return time.Now() return time.Now()
} }
hash := md5.New() //#nosec G401 // Used to derive a static jitter checksum, not cryptographically
fmt.Fprint(hash, ce.Key())
var jitter int64 var jitter int64
for i, c := range hash.Sum(nil) { //#nosec G401 // Used to derive a static jitter checksum, not cryptographically
jitter += int64(c) * int64(math.Pow(10, float64(i))) //nolint:gomnd // No need for constant here for i, c := range md5.Sum([]byte(ce.Key())) {
jitter += int64(c) * int64(math.Pow(10, float64(i))) //nolint:mnd // No need for constant here
} }
next := lastCheck. next := lastCheck.