Update linting

* Update golangci-lint from upstream prometheus repo.
* Ignore min/max in predeclared.
* Fix `Errorf()` use.

Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
SuperQ 2024-08-30 18:02:53 +02:00
parent dbf72fc1a2
commit e080e48d5b
No known key found for this signature in database
GPG Key ID: C646B23C9E3245F1
5 changed files with 10 additions and 6 deletions

View File

@ -36,4 +36,4 @@ jobs:
uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0 uses: golangci/golangci-lint-action@aaa42aa0628b4ae2578232a66b541047968fac86 # v6.1.0
with: with:
args: --verbose args: --verbose
version: v1.59.1 version: v1.60.2

View File

@ -66,6 +66,8 @@ linters-settings:
local-prefixes: github.com/prometheus/client_golang local-prefixes: github.com/prometheus/client_golang
gofumpt: gofumpt:
extra-rules: true extra-rules: true
predeclared:
ignore: "min,max"
revive: revive:
rules: rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter

View File

@ -61,7 +61,7 @@ PROMU_URL := https://github.com/prometheus/promu/releases/download/v$(PROMU_
SKIP_GOLANGCI_LINT := SKIP_GOLANGCI_LINT :=
GOLANGCI_LINT := GOLANGCI_LINT :=
GOLANGCI_LINT_OPTS ?= GOLANGCI_LINT_OPTS ?=
GOLANGCI_LINT_VERSION ?= v1.59.1 GOLANGCI_LINT_VERSION ?= v1.60.2
# golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64. # golangci-lint only supports linux, darwin and windows platforms on i386/amd64/arm64.
# windows isn't included here because of the path separator being different. # windows isn't included here because of the path separator being different.
ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin)) ifeq ($(GOHOSTOS),$(filter $(GOHOSTOS),linux darwin))

View File

@ -17,6 +17,7 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"context" "context"
"errors"
"fmt" "fmt"
"io" "io"
"log" "log"
@ -238,7 +239,7 @@ prefix.name_bucket;constname=constvalue;labelname=val2;le=+Inf 3 1477043
got := buf.String() got := buf.String()
if err := checkLinesAreEqual(want, got, useTags); err != nil { if err := checkLinesAreEqual(want, got, useTags); err != nil {
t.Fatalf(err.Error()) t.Fatal(err.Error())
} }
} }
@ -290,7 +291,7 @@ prefix.name;constname=constvalue;labelname=val2 1 1477043
got := buf.String() got := buf.String()
if err := checkLinesAreEqual(want, got, useTags); err != nil { if err := checkLinesAreEqual(want, got, useTags); err != nil {
t.Fatalf(err.Error()) t.Fatal(err.Error())
} }
} }
@ -322,7 +323,7 @@ func checkLinesAreEqual(w, g string, useTags bool) error {
log += fmt.Sprintf("want: %v\ngot: %v\n\n", wantSplit, gotSplit) log += fmt.Sprintf("want: %v\ngot: %v\n\n", wantSplit, gotSplit)
if !reflect.DeepEqual(wantSplit, gotSplit) { if !reflect.DeepEqual(wantSplit, gotSplit) {
return fmt.Errorf(log) return errors.New(log)
} }
} }
return nil return nil

View File

@ -39,6 +39,7 @@ package testutil
import ( import (
"bytes" "bytes"
"errors"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -310,7 +311,7 @@ func compare(got, want []*dto.MetricFamily) error {
} }
} }
if diffErr := diff.Diff(gotBuf.String(), wantBuf.String()); diffErr != "" { if diffErr := diff.Diff(gotBuf.String(), wantBuf.String()); diffErr != "" {
return fmt.Errorf(diffErr) return errors.New(diffErr)
} }
return nil return nil
} }