Skip to content

Commit 35e7243

Browse files
committed
permanently enable the linters
Signed-off-by: Christoph Mewes <[email protected]>
1 parent 13d45b1 commit 35e7243

File tree

6 files changed

+30
-9
lines changed

6 files changed

+30
-9
lines changed

.golangci.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,26 @@ output:
88

99
linters:
1010
enable:
11+
- deadcode
12+
- depguard
13+
- durationcheck
14+
- errorlint
15+
- exportloopref
16+
- gofmt
1117
- gofumpt
1218
- goimports
13-
- revive
19+
- gosimple
20+
- ineffassign
1421
- misspell
22+
- nolintlint
23+
- predeclared
24+
- revive
25+
- staticcheck
26+
- structcheck
27+
- unconvert
28+
- unused
29+
- varcheck
30+
- wastedassign
1531

1632
issues:
1733
max-same-issues: 0

api/prometheus/v1/api_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,9 +1484,13 @@ func TestAPIClientDo(t *testing.T) {
14841484
}
14851485

14861486
if test.expectedErr.Detail != "" {
1487-
apiErr := err.(*Error)
1488-
if apiErr.Detail != test.expectedErr.Detail {
1489-
t.Fatalf("expected error detail :%v, but got:%v", apiErr.Detail, test.expectedErr.Detail)
1487+
apiErr := &Error{}
1488+
if errors.As(err, &apiErr) {
1489+
if apiErr.Detail != test.expectedErr.Detail {
1490+
t.Fatalf("expected error detail :%v, but got:%v", apiErr.Detail, test.expectedErr.Detail)
1491+
}
1492+
} else {
1493+
t.Fatalf("expected v1.Error instance, but got:%T", err)
14901494
}
14911495
}
14921496

prometheus/process_collector.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ func NewPidFileFn(pidFilePath string) func() (int, error) {
153153
return func() (int, error) {
154154
content, err := os.ReadFile(pidFilePath)
155155
if err != nil {
156-
return 0, fmt.Errorf("can't read pid file %q: %+v", pidFilePath, err)
156+
return 0, fmt.Errorf("can't read pid file %q: %w", pidFilePath, err)
157157
}
158158
pid, err := strconv.Atoi(strings.TrimSpace(string(content)))
159159
if err != nil {
160-
return 0, fmt.Errorf("can't parse pid file %q: %+v", pidFilePath, err)
160+
return 0, fmt.Errorf("can't parse pid file %q: %w", pidFilePath, err)
161161
}
162162

163163
return pid, nil

prometheus/promhttp/instrument_server_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ func TestLabelCheck(t *testing.T) {
146146
},
147147
append(sc.varLabels, sc.curriedLabels...),
148148
))
149-
//nolint:typecheck // Ignore declared but unused error.
150149
for _, l := range sc.curriedLabels {
151150
c = c.MustCurryWith(prometheus.Labels{l: "dummy"})
152151
o = o.MustCurryWith(prometheus.Labels{l: "dummy"})

prometheus/registry.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package prometheus
1515

1616
import (
1717
"bytes"
18+
"errors"
1819
"fmt"
1920
"os"
2021
"path/filepath"
@@ -724,7 +725,8 @@ func (gs Gatherers) Gather() ([]*dto.MetricFamily, error) {
724725
for i, g := range gs {
725726
mfs, err := g.Gather()
726727
if err != nil {
727-
if multiErr, ok := err.(MultiError); ok {
728+
multiErr := MultiError{}
729+
if errors.As(err, &multiErr) {
728730
for _, err := range multiErr {
729731
errs = append(errs, fmt.Errorf("[from Gatherer #%d] %w", i+1, err))
730732
}

prometheus/registry_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ func TestNewMultiTRegistry(t *testing.T) {
12411241
t.Run("two registries, one with error", func(t *testing.T) {
12421242
m := prometheus.NewMultiTRegistry(prometheus.ToTransactionalGatherer(reg), treg)
12431243
ret, done, err := m.Gather()
1244-
if err != treg.err {
1244+
if !errors.Is(err, treg.err) {
12451245
t.Error("unexpected error:", err)
12461246
}
12471247
done()

0 commit comments

Comments
 (0)