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
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

20 changes: 20 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
version: "2"
run:
timeout: 5m
tests: false
linters:
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.
)
4 changes: 2 additions & 2 deletions json.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (cmd *JSONCmd) Expanded() (interface{}, error) {

func (cmd *JSONCmd) readReply(rd *proto.Reader) error {
// nil response from JSON.(M)GET (cmd.baseCmd.err will be "redis: nil")
if cmd.baseCmd.Err() == Nil {
if cmd.Err() == Nil {
cmd.val = ""
return Nil
}
Expand Down Expand Up @@ -182,7 +182,7 @@ func (cmd *JSONSliceCmd) Result() ([]interface{}, error) {
}

func (cmd *JSONSliceCmd) readReply(rd *proto.Reader) error {
if cmd.baseCmd.Err() == Nil {
if cmd.Err() == Nil {
cmd.val = nil
return Nil
}
Expand Down
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
18 changes: 9 additions & 9 deletions redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,16 +677,16 @@ func NewClient(opt *Options) *Client {
func (c *Client) init() {
c.cmdable = c.Process
c.initHooks(hooks{
dial: c.baseClient.dial,
process: c.baseClient.process,
pipeline: c.baseClient.processPipeline,
txPipeline: c.baseClient.processTxPipeline,
dial: c.dial,
process: c.process,
pipeline: c.processPipeline,
txPipeline: c.processTxPipeline,
})
}

func (c *Client) WithTimeout(timeout time.Duration) *Client {
clone := *c
clone.baseClient = c.baseClient.withTimeout(timeout)
clone.baseClient = c.withTimeout(timeout)
clone.init()
return &clone
}
Expand Down Expand Up @@ -839,10 +839,10 @@ func newConn(opt *Options, connPool pool.Pooler) *Conn {
c.cmdable = c.Process
c.statefulCmdable = c.Process
c.initHooks(hooks{
dial: c.baseClient.dial,
process: c.baseClient.process,
pipeline: c.baseClient.processPipeline,
txPipeline: c.baseClient.processTxPipeline,
dial: c.dial,
process: c.process,
pipeline: c.processPipeline,
txPipeline: c.processTxPipeline,
})

return &c
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
4 changes: 2 additions & 2 deletions sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ func NewSentinelClient(opt *Options) *SentinelClient {
}

c.initHooks(hooks{
dial: c.baseClient.dial,
process: c.baseClient.process,
dial: c.dial,
process: c.process,
})
c.connPool = newConnPool(opt, c.dialHook)

Expand Down
8 changes: 4 additions & 4 deletions tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func (c *Tx) init() {
c.statefulCmdable = c.Process

c.initHooks(hooks{
dial: c.baseClient.dial,
process: c.baseClient.process,
pipeline: c.baseClient.processPipeline,
txPipeline: c.baseClient.processTxPipeline,
dial: c.dial,
process: c.process,
pipeline: c.processPipeline,
txPipeline: c.processTxPipeline,
})
}

Expand Down
Loading