Skip to content

Commit 2f0a9b7

Browse files
authored
migrate golangci-lint config to v2 format (#3354)
* migrate golangci-lint config to v2 format * chore: skip CI on migration [skip ci] * Bump golangci version * Address several golangci-lint/staticcheck warnings * change staticchecks settings
1 parent bb8d508 commit 2f0a9b7

File tree

12 files changed

+57
-22
lines changed

12 files changed

+57
-22
lines changed

.github/workflows/golangci-lint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
steps:
2222
- uses: actions/checkout@v4
2323
- name: golangci-lint
24-
uses: golangci/golangci-lint-action@v6.5.2
24+
uses: golangci/golangci-lint-action@v7.0.0
2525
with:
26-
verify: false # disable verifying the configuration since golangci is currently introducing breaking changes in the configuration
26+
verify: true
2727

.golangci.yml

+31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
version: "2"
12
run:
23
timeout: 5m
34
tests: false
5+
linters:
6+
settings:
7+
staticcheck:
8+
checks:
9+
- all
10+
# Incorrect or missing package comment.
11+
# https://staticcheck.dev/docs/checks/#ST1000
12+
- -ST1000
13+
# Omit embedded fields from selector expression.
14+
# https://staticcheck.dev/docs/checks/#QF1008
15+
- -QF1008
16+
- -ST1003
17+
exclusions:
18+
generated: lax
19+
presets:
20+
- comments
21+
- common-false-positives
22+
- legacy
23+
- std-error-handling
24+
paths:
25+
- third_party$
26+
- builtin$
27+
- examples$
28+
formatters:
29+
exclusions:
30+
generated: lax
31+
paths:
32+
- third_party$
33+
- builtin$
34+
- examples$

command.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -1412,7 +1412,8 @@ func (cmd *MapStringSliceInterfaceCmd) readReply(rd *proto.Reader) (err error) {
14121412

14131413
cmd.val = make(map[string][]interface{})
14141414

1415-
if readType == proto.RespMap {
1415+
switch readType {
1416+
case proto.RespMap:
14161417
n, err := rd.ReadMapLen()
14171418
if err != nil {
14181419
return err
@@ -1435,7 +1436,7 @@ func (cmd *MapStringSliceInterfaceCmd) readReply(rd *proto.Reader) (err error) {
14351436
cmd.val[k][j] = value
14361437
}
14371438
}
1438-
} else if readType == proto.RespArray {
1439+
case proto.RespArray:
14391440
// RESP2 response
14401441
n, err := rd.ReadArrayLen()
14411442
if err != nil {

extra/rediscensus/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ require (
1919
)
2020

2121
retract (
22-
v9.5.3 // This version was accidentally released.
2322
v9.7.2 // This version was accidentally released.
23+
v9.5.3 // This version was accidentally released.
2424
)

extra/rediscmd/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ require (
1616
)
1717

1818
retract (
19-
v9.5.3 // This version was accidentally released.
2019
v9.7.2 // This version was accidentally released.
20+
v9.5.3 // This version was accidentally released.
2121
)

extra/redisotel/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ require (
2424
)
2525

2626
retract (
27-
v9.5.3 // This version was accidentally released.
2827
v9.7.2 // This version was accidentally released.
28+
v9.5.3 // This version was accidentally released.
2929
)

extra/redisprometheus/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ require (
2323
)
2424

2525
retract (
26-
v9.5.3 // This version was accidentally released.
2726
v9.7.2 // This version was accidentally released.
27+
v9.5.3 // This version was accidentally released.
2828
)

options.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,10 @@ func (opt *Options) init() {
214214
opt.ConnMaxIdleTime = 30 * time.Minute
215215
}
216216

217-
if opt.MaxRetries == -1 {
217+
switch opt.MaxRetries {
218+
case -1:
218219
opt.MaxRetries = 0
219-
} else if opt.MaxRetries == 0 {
220+
case 0:
220221
opt.MaxRetries = 3
221222
}
222223
switch opt.MinRetryBackoff {

osscluster.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,10 @@ type ClusterOptions struct {
111111
}
112112

113113
func (opt *ClusterOptions) init() {
114-
if opt.MaxRedirects == -1 {
114+
switch opt.MaxRedirects {
115+
case -1:
115116
opt.MaxRedirects = 0
116-
} else if opt.MaxRedirects == 0 {
117+
case 0:
117118
opt.MaxRedirects = 3
118119
}
119120

ring.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,10 @@ func (opt *RingOptions) init() {
128128
opt.NewConsistentHash = newRendezvous
129129
}
130130

131-
if opt.MaxRetries == -1 {
131+
switch opt.MaxRetries {
132+
case -1:
132133
opt.MaxRetries = 0
133-
} else if opt.MaxRetries == 0 {
134+
case 0:
134135
opt.MaxRetries = 3
135136
}
136137
switch opt.MinRetryBackoff {

sentinel_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var _ = Describe("Sentinel resolution", func() {
4141
client := redis.NewFailoverClient(&redis.FailoverOptions{
4242
MasterName: sentinelName,
4343
SentinelAddrs: sentinelAddrs,
44-
MaxRetries: -1,
44+
MaxRetries: -1,
4545
})
4646

4747
err := client.Ping(shortCtx).Err()

universal.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,13 @@ var (
259259
// NewUniversalClient returns a new multi client. The type of the returned client depends
260260
// on the following conditions:
261261
//
262-
// 1. If the MasterName option is specified with RouteByLatency, RouteRandomly or IsClusterMode,
263-
// a FailoverClusterClient is returned.
264-
// 2. If the MasterName option is specified without RouteByLatency, RouteRandomly or IsClusterMode,
265-
// a sentinel-backed FailoverClient is returned.
266-
// 3. If the number of Addrs is two or more, or IsClusterMode option is specified,
267-
// a ClusterClient is returned.
268-
// 4. Otherwise, a single-node Client is returned.
262+
// 1. If the MasterName option is specified with RouteByLatency, RouteRandomly or IsClusterMode,
263+
// a FailoverClusterClient is returned.
264+
// 2. If the MasterName option is specified without RouteByLatency, RouteRandomly or IsClusterMode,
265+
// a sentinel-backed FailoverClient is returned.
266+
// 3. If the number of Addrs is two or more, or IsClusterMode option is specified,
267+
// a ClusterClient is returned.
268+
// 4. Otherwise, a single-node Client is returned.
269269
func NewUniversalClient(opts *UniversalOptions) UniversalClient {
270270
switch {
271271
case opts.MasterName != "" && (opts.RouteByLatency || opts.RouteRandomly || opts.IsClusterMode):

0 commit comments

Comments
 (0)