Skip to content

Commit

Permalink
permanently enable the linters
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Mewes <christoph@kubermatic.com>
  • Loading branch information
xrstf committed Jun 17, 2022
1 parent d3603e0 commit 682e474
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
18 changes: 17 additions & 1 deletion .golangci.yml
Expand Up @@ -8,10 +8,26 @@ output:

linters:
enable:
- deadcode
- depguard
- durationcheck
- errorlint
- exportloopref
- gofmt
- gofumpt
- goimports
- revive
- gosimple
- ineffassign
- misspell
- nolintlint
- predeclared
- revive
- staticcheck
- structcheck
- unconvert
- unused
- varcheck
- wastedassign

issues:
max-same-issues: 0
Expand Down
10 changes: 7 additions & 3 deletions api/prometheus/v1/api_test.go
Expand Up @@ -1455,9 +1455,13 @@ func TestAPIClientDo(t *testing.T) {
}

if test.expectedErr.Detail != "" {
apiErr := err.(*Error)
if apiErr.Detail != test.expectedErr.Detail {
t.Fatalf("expected error detail :%v, but got:%v", apiErr.Detail, test.expectedErr.Detail)
apiErr := &Error{}
if errors.As(err, &apiErr) {
if apiErr.Detail != test.expectedErr.Detail {
t.Fatalf("expected error detail :%v, but got:%v", apiErr.Detail, test.expectedErr.Detail)
}
} else {
t.Fatalf("expected v1.Error instance, but got:%T", err)
}
}

Expand Down
4 changes: 2 additions & 2 deletions prometheus/process_collector.go
Expand Up @@ -154,11 +154,11 @@ func NewPidFileFn(pidFilePath string) func() (int, error) {
return func() (int, error) {
content, err := ioutil.ReadFile(pidFilePath)
if err != nil {
return 0, fmt.Errorf("can't read pid file %q: %+v", pidFilePath, err)
return 0, fmt.Errorf("can't read pid file %q: %w", pidFilePath, err)
}
pid, err := strconv.Atoi(strings.TrimSpace(string(content)))
if err != nil {
return 0, fmt.Errorf("can't parse pid file %q: %+v", pidFilePath, err)
return 0, fmt.Errorf("can't parse pid file %q: %w", pidFilePath, err)
}

return pid, nil
Expand Down
1 change: 0 additions & 1 deletion prometheus/promhttp/instrument_server_test.go
Expand Up @@ -145,7 +145,6 @@ func TestLabelCheck(t *testing.T) {
},
append(sc.varLabels, sc.curriedLabels...),
))
//nolint:typecheck // Ignore declared but unused error.
for _, l := range sc.curriedLabels {
c = c.MustCurryWith(prometheus.Labels{l: "dummy"})
o = o.MustCurryWith(prometheus.Labels{l: "dummy"})
Expand Down
4 changes: 3 additions & 1 deletion prometheus/registry.go
Expand Up @@ -15,6 +15,7 @@ package prometheus

import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"os"
Expand Down Expand Up @@ -725,7 +726,8 @@ func (gs Gatherers) Gather() ([]*dto.MetricFamily, error) {
for i, g := range gs {
mfs, err := g.Gather()
if err != nil {
if multiErr, ok := err.(MultiError); ok {
multiErr := MultiError{}
if errors.As(err, &multiErr) {
for _, err := range multiErr {
errs = append(errs, fmt.Errorf("[from Gatherer #%d] %w", i+1, err))
}
Expand Down
2 changes: 1 addition & 1 deletion prometheus/registry_test.go
Expand Up @@ -1242,7 +1242,7 @@ func TestNewMultiTRegistry(t *testing.T) {
t.Run("two registries, one with error", func(t *testing.T) {
m := prometheus.NewMultiTRegistry(prometheus.ToTransactionalGatherer(reg), treg)
ret, done, err := m.Gather()
if err != treg.err {
if !errors.Is(err, treg.err) {
t.Error("unexpected error:", err)
}
done()
Expand Down

0 comments on commit 682e474

Please sign in to comment.