Skip to content

Commit e789919

Browse files
committed
Upgrade golangci-lint from v1 to v2
- Update GOLANGCI_LINT_VERSION from v1.64.8 to v2.0.2 - Migrate .golangci.yml to v2 format: - Add version: "2" declaration - Move linters-settings under linters.settings Tracking: redhat-best-practices-for-k8s/telco-bot#49
1 parent 12cc47e commit e789919

3 files changed

Lines changed: 29 additions & 23 deletions

File tree

.golangci.yml

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
1+
version: "2"
12
linters:
2-
# disable-all: true
3-
# enable-all: true
4-
disable:
5-
- megacheck
63
enable:
7-
# megacheck fails to respect build flags, causing compilation failure during linting.
8-
# instead, use the unused, gosimple, and staticcheck linters directly
9-
- gosimple
104
- staticcheck
115
- unused
12-
linters-settings:
13-
errcheck:
14-
exclude: .errcheck_excludes.txt
15-
govet:
16-
# disable for those few tests calling t.Fatal from withing go routine.
17-
disable:
18-
- testinggoroutine
6+
settings:
7+
errcheck:
8+
# Exclude functions from error checking
9+
exclude-functions:
10+
- (github.com/go-kit/log.Logger).Log
11+
- (net.Listener).Close
12+
- (*net/http.Response).Body.Close
13+
- (io.Closer).Close
14+
- io.Closer.Close
15+
- fmt.Fprintln
16+
- fmt.Fprintf
17+
govet:
18+
# Disable testinggoroutine for tests calling t.Fatal from goroutines
19+
disable:
20+
- testinggoroutine
21+
staticcheck:
22+
# Disable checks that were not enforced in v1 configuration
23+
checks:
24+
- all
25+
- "-SA2002" # t.Fatal in goroutine (same as govet's testinggoroutine)
26+
- "-SA1019" # deprecated APIs (existing code, not introduced by this PR)
27+
- "-SA4006" # unused value assignments (will fix separately)
28+
- "-SA4001" # *&x simplification
29+
- "-ST1000" # package comments
30+
- "-ST1005" # error string capitalization
31+
- "-ST1020" # function comment format
32+
- "-QF1002" # tagged switch suggestion

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ LIB_DIR?=./_output/lib
1313
CACHE_DIR?=$(shell pwd)/_output/cache
1414
METRICS_JSON=./_output/metrics.json
1515
GOLANGCI_LINT_BIN=$(BIN_DIR)/golangci-lint
16-
GOLANGCI_LINT_VERSION=v1.64.8
16+
GOLANGCI_LINT_VERSION=v2.0.2
1717
THANOS_BIN=$(BIN_DIR)/thanos
1818
OTELCOL_BIN=$(BIN_DIR)/otelcol
1919
PROMETHEUS_BIN=$(BIN_DIR)/prometheus

pkg/runutil/runutil_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ import (
1313
"github.com/pkg/errors"
1414
)
1515

16-
type testCloser struct {
17-
err error
18-
}
19-
20-
func (c testCloser) Close() error {
21-
return c.err
22-
}
23-
2416
type loggerCapturer struct {
2517
// WasCalled is true if the Log() function has been called.
2618
WasCalled bool

0 commit comments

Comments
 (0)