Skip to content

migrate golangci-lint config to v2 format #3354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 29, 2025
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6.5.2
uses: golangci/golangci-lint-action@v7.0.0
with:
verify: false # disable verifying the configuration since golangci is currently introducing breaking changes in the configuration
verify: true

31 changes: 31 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
version: "2"
run:
timeout: 5m
tests: false
linters:
settings:
staticcheck:
checks:
- all
# Incorrect or missing package comment.
# https://staticcheck.dev/docs/checks/#ST1000
- -ST1000
# Omit embedded fields from selector expression.
# https://staticcheck.dev/docs/checks/#QF1008
- -QF1008
- -ST1003
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
5 changes: 3 additions & 2 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,8 @@ func (cmd *MapStringSliceInterfaceCmd) readReply(rd *proto.Reader) (err error) {

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

if readType == proto.RespMap {
switch readType {
case proto.RespMap:
n, err := rd.ReadMapLen()
if err != nil {
return err
Expand All @@ -1435,7 +1436,7 @@ func (cmd *MapStringSliceInterfaceCmd) readReply(rd *proto.Reader) (err error) {
cmd.val[k][j] = value
}
}
} else if readType == proto.RespArray {
case proto.RespArray:
// RESP2 response
n, err := rd.ReadArrayLen()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion extra/rediscensus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ require (
)

retract (
v9.5.3 // This version was accidentally released.
v9.7.2 // This version was accidentally released.
v9.5.3 // This version was accidentally released.
)
2 changes: 1 addition & 1 deletion extra/rediscmd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ require (
)

retract (
v9.5.3 // This version was accidentally released.
v9.7.2 // This version was accidentally released.
v9.5.3 // This version was accidentally released.
)
2 changes: 1 addition & 1 deletion extra/redisotel/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ require (
)

retract (
v9.5.3 // This version was accidentally released.
v9.7.2 // This version was accidentally released.
v9.5.3 // This version was accidentally released.
)
2 changes: 1 addition & 1 deletion extra/redisprometheus/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ require (
)

retract (
v9.5.3 // This version was accidentally released.
v9.7.2 // This version was accidentally released.
v9.5.3 // This version was accidentally released.
)
5 changes: 3 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,10 @@ func (opt *Options) init() {
opt.ConnMaxIdleTime = 30 * time.Minute
}

if opt.MaxRetries == -1 {
switch opt.MaxRetries {
case -1:
opt.MaxRetries = 0
} else if opt.MaxRetries == 0 {
case 0:
opt.MaxRetries = 3
}
switch opt.MinRetryBackoff {
Expand Down
5 changes: 3 additions & 2 deletions osscluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ type ClusterOptions struct {
}

func (opt *ClusterOptions) init() {
if opt.MaxRedirects == -1 {
switch opt.MaxRedirects {
case -1:
opt.MaxRedirects = 0
} else if opt.MaxRedirects == 0 {
case 0:
opt.MaxRedirects = 3
}

Expand Down
5 changes: 3 additions & 2 deletions ring.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ func (opt *RingOptions) init() {
opt.NewConsistentHash = newRendezvous
}

if opt.MaxRetries == -1 {
switch opt.MaxRetries {
case -1:
opt.MaxRetries = 0
} else if opt.MaxRetries == 0 {
case 0:
opt.MaxRetries = 3
}
switch opt.MinRetryBackoff {
Expand Down
2 changes: 1 addition & 1 deletion sentinel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var _ = Describe("Sentinel resolution", func() {
client := redis.NewFailoverClient(&redis.FailoverOptions{
MasterName: sentinelName,
SentinelAddrs: sentinelAddrs,
MaxRetries: -1,
MaxRetries: -1,
})

err := client.Ping(shortCtx).Err()
Expand Down
14 changes: 7 additions & 7 deletions universal.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,13 @@ var (
// NewUniversalClient returns a new multi client. The type of the returned client depends
// on the following conditions:
//
// 1. If the MasterName option is specified with RouteByLatency, RouteRandomly or IsClusterMode,
// a FailoverClusterClient is returned.
// 2. If the MasterName option is specified without RouteByLatency, RouteRandomly or IsClusterMode,
// a sentinel-backed FailoverClient is returned.
// 3. If the number of Addrs is two or more, or IsClusterMode option is specified,
// a ClusterClient is returned.
// 4. Otherwise, a single-node Client is returned.
// 1. If the MasterName option is specified with RouteByLatency, RouteRandomly or IsClusterMode,
// a FailoverClusterClient is returned.
// 2. If the MasterName option is specified without RouteByLatency, RouteRandomly or IsClusterMode,
// a sentinel-backed FailoverClient is returned.
// 3. If the number of Addrs is two or more, or IsClusterMode option is specified,
// a ClusterClient is returned.
// 4. Otherwise, a single-node Client is returned.
func NewUniversalClient(opts *UniversalOptions) UniversalClient {
switch {
case opts.MasterName != "" && (opts.RouteByLatency || opts.RouteRandomly || opts.IsClusterMode):
Expand Down
Loading