Skip to content

Commit 72fabf5

Browse files
committed
Address several golangci-lint/staticcheck warnings
1 parent 2f4c38b commit 72fabf5

File tree

12 files changed

+33
-29
lines changed

12 files changed

+33
-29
lines changed

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
)

json.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func (cmd *JSONCmd) Expanded() (interface{}, error) {
113113

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

184184
func (cmd *JSONSliceCmd) readReply(rd *proto.Reader) error {
185-
if cmd.baseCmd.Err() == Nil {
185+
if cmd.Err() == Nil {
186186
cmd.val = nil
187187
return Nil
188188
}

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

redis.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -677,16 +677,16 @@ func NewClient(opt *Options) *Client {
677677
func (c *Client) init() {
678678
c.cmdable = c.Process
679679
c.initHooks(hooks{
680-
dial: c.baseClient.dial,
681-
process: c.baseClient.process,
682-
pipeline: c.baseClient.processPipeline,
683-
txPipeline: c.baseClient.processTxPipeline,
680+
dial: c.dial,
681+
process: c.process,
682+
pipeline: c.processPipeline,
683+
txPipeline: c.processTxPipeline,
684684
})
685685
}
686686

687687
func (c *Client) WithTimeout(timeout time.Duration) *Client {
688688
clone := *c
689-
clone.baseClient = c.baseClient.withTimeout(timeout)
689+
clone.baseClient = c.withTimeout(timeout)
690690
clone.init()
691691
return &clone
692692
}
@@ -839,10 +839,10 @@ func newConn(opt *Options, connPool pool.Pooler) *Conn {
839839
c.cmdable = c.Process
840840
c.statefulCmdable = c.Process
841841
c.initHooks(hooks{
842-
dial: c.baseClient.dial,
843-
process: c.baseClient.process,
844-
pipeline: c.baseClient.processPipeline,
845-
txPipeline: c.baseClient.processTxPipeline,
842+
dial: c.dial,
843+
process: c.process,
844+
pipeline: c.processPipeline,
845+
txPipeline: c.processTxPipeline,
846846
})
847847

848848
return &c

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.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ func NewSentinelClient(opt *Options) *SentinelClient {
321321
}
322322

323323
c.initHooks(hooks{
324-
dial: c.baseClient.dial,
325-
process: c.baseClient.process,
324+
dial: c.dial,
325+
process: c.process,
326326
})
327327
c.connPool = newConnPool(opt, c.dialHook)
328328

tx.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ func (c *Tx) init() {
3939
c.statefulCmdable = c.Process
4040

4141
c.initHooks(hooks{
42-
dial: c.baseClient.dial,
43-
process: c.baseClient.process,
44-
pipeline: c.baseClient.processPipeline,
45-
txPipeline: c.baseClient.processTxPipeline,
42+
dial: c.dial,
43+
process: c.process,
44+
pipeline: c.processPipeline,
45+
txPipeline: c.processTxPipeline,
4646
})
4747
}
4848

0 commit comments

Comments
 (0)