Skip to content

Commit

Permalink
Fix golangci-lint check
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Mar 23, 2021
1 parent e3c1e88 commit 02a9c81
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ linters:
- exhaustivestruct
- wrapcheck
- errorlint
- cyclop
- forcetypeassert
18 changes: 10 additions & 8 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,9 @@ func (c *clusterNodes) Close() error {

func (c *clusterNodes) Addrs() ([]string, error) {
var addrs []string

c.mu.RLock()
closed := c.closed
closed := c.closed //nolint:ifshort
if !closed {
if len(c.activeAddrs) > 0 {
addrs = c.activeAddrs
Expand Down Expand Up @@ -649,14 +650,15 @@ func (c *clusterStateHolder) LazyReload() {

func (c *clusterStateHolder) Get(ctx context.Context) (*clusterState, error) {
v := c.state.Load()
if v != nil {
state := v.(*clusterState)
if time.Since(state.createdAt) > 10*time.Second {
c.LazyReload()
}
return state, nil
if v == nil {
return c.Reload(ctx)
}
return c.Reload(ctx)

state := v.(*clusterState)
if time.Since(state.createdAt) > 10*time.Second {
c.LazyReload()
}
return state, nil
}

func (c *clusterStateHolder) ReloadOrGet(ctx context.Context) (*clusterState, error) {
Expand Down
20 changes: 8 additions & 12 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -1989,12 +1989,10 @@ func (c cmdable) ZIncrBy(ctx context.Context, key string, increment float64, mem
}

func (c cmdable) ZInterStore(ctx context.Context, destination string, store *ZStore) *IntCmd {
args := make([]interface{}, 3+len(store.Keys))
args[0] = "zinterstore"
args[1] = destination
args[2] = len(store.Keys)
for i, key := range store.Keys {
args[3+i] = key
args := make([]interface{}, 0, 3+len(store.Keys))
args = append(args, "zinterstore", destination, len(store.Keys))
for _, key := range store.Keys {
args = append(args, key)
}
if len(store.Weights) > 0 {
args = append(args, "weights")
Expand Down Expand Up @@ -2237,12 +2235,10 @@ func (c cmdable) ZScore(ctx context.Context, key, member string) *FloatCmd {
}

func (c cmdable) ZUnionStore(ctx context.Context, dest string, store *ZStore) *IntCmd {
args := make([]interface{}, 3+len(store.Keys))
args[0] = "zunionstore"
args[1] = dest
args[2] = len(store.Keys)
for i, key := range store.Keys {
args[3+i] = key
args := make([]interface{}, 0, 3+len(store.Keys))
args = append(args, "zunionstore", dest, len(store.Keys))
for _, key := range store.Keys {
args = append(args, key)
}
if len(store.Weights) > 0 {
args = append(args, "weights")
Expand Down
3 changes: 1 addition & 2 deletions internal/pool/pool_sticky.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ func (p *StickyConnPool) Reset(ctx context.Context) error {

func (p *StickyConnPool) badConnError() error {
if v := p._badConnError.Load(); v != nil {
err := v.(BadConnError)
if err.wrapped != nil {
if err := v.(BadConnError); err.wrapped != nil {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/proto/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (r *Reader) readLine() ([]byte, error) {
return nil, err
}

full = append(full, b...)
full = append(full, b...) //nolint:makezero
b = full
}
if len(b) <= 2 || b[len(b)-1] != '\n' || b[len(b)-2] != '\r' {
Expand Down
1 change: 0 additions & 1 deletion internal/proto/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
)

// Scan parses bytes `b` to `v` with appropriate type.
// nolint: gocyclo
func Scan(b []byte, v interface{}) error {
switch v := v.(type) {
case nil:
Expand Down
2 changes: 1 addition & 1 deletion pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func mapKeys(m map[string]struct{}) []string {
i := 0
for k := range m {
s[i] = k
i++
i++ // nolint:wastedassign
}
return s
}
Expand Down
3 changes: 2 additions & 1 deletion redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ func (c *baseClient) withConn(
c.releaseConn(ctx, cn, err)
}()

done := ctx.Done()
done := ctx.Done() //nolint:ifshort

if done == nil {
err = fn(ctx, cn)
return err
Expand Down
2 changes: 1 addition & 1 deletion sentinel.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ func parseSlaveAddrs(addrs []interface{}, keepDisconnected bool) []string {

func (c *sentinelFailover) trySwitchMaster(ctx context.Context, addr string) {
c.mu.RLock()
currentAddr := c._masterAddr
currentAddr := c._masterAddr //nolint:ifshort
c.mu.RUnlock()

if addr == currentAddr {
Expand Down

0 comments on commit 02a9c81

Please sign in to comment.