Skip to content

Commit

Permalink
Fix golangci
Browse files Browse the repository at this point in the history
  • Loading branch information
vmihailenco committed Jul 16, 2020
1 parent 14c843e commit 38c87c1
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 48 deletions.
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ linters:
disable:
- funlen
- gochecknoglobals
- gochecknoinits
- gocognit
- goconst
- godox
- gosec
- maligned
- wsl
- gomnd
- goerr113
- exhaustive
- gofumpt
- nestif
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ env:
go_import_path: github.com/go-redis/redis

before_install:
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.21.0
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s --
-b $(go env GOPATH)/bin v1.28.3
15 changes: 0 additions & 15 deletions cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1655,21 +1655,6 @@ loop:
return ss
}

func remove(ss []string, es ...string) []string {
if len(es) == 0 {
return ss[:0]
}
for _, e := range es {
for i, s := range ss {
if s == e {
ss = append(ss[:i], ss[i+1:]...)
break
}
}
}
return ss
}

//------------------------------------------------------------------------------

type cmdsMap struct {
Expand Down
6 changes: 3 additions & 3 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (cmd *Cmd) readReply(rd *proto.Reader) error {
return cmd.err
}

// Implements proto.MultiBulkParse
// sliceParser implements proto.MultiBulkParse.
func sliceParser(rd *proto.Reader, n int64) (interface{}, error) {
vals := make([]interface{}, n)
for i := 0; i < len(vals); i++ {
Expand Down Expand Up @@ -1072,7 +1072,7 @@ func (cmd *XMessageSliceCmd) readReply(rd *proto.Reader) error {
return nil
}

// Implements proto.MultiBulkParse
// xMessageSliceParser implements proto.MultiBulkParse.
func xMessageSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
msgs := make([]XMessage, n)
for i := 0; i < len(msgs); i++ {
Expand Down Expand Up @@ -1107,7 +1107,7 @@ func xMessageSliceParser(rd *proto.Reader, n int64) (interface{}, error) {
return msgs, nil
}

// Implements proto.MultiBulkParse
// stringInterfaceMapParser implements proto.MultiBulkParse.
func stringInterfaceMapParser(rd *proto.Reader, n int64) (interface{}, error) {
m := make(map[string]interface{}, n/2)
for i := int64(0); i < n; i += 2 {
Expand Down
7 changes: 4 additions & 3 deletions commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -1315,14 +1315,14 @@ func (c cmdable) SIsMember(ctx context.Context, key string, member interface{})
return cmd
}

// Redis `SMEMBERS key` command output as a slice
// Redis `SMEMBERS key` command output as a slice.
func (c cmdable) SMembers(ctx context.Context, key string) *StringSliceCmd {
cmd := NewStringSliceCmd(ctx, "smembers", key)
_ = c(ctx, cmd)
return cmd
}

// Redis `SMEMBERS key` command output as a map
// Redis `SMEMBERS key` command output as a map.
func (c cmdable) SMembersMap(ctx context.Context, key string) *StringStructMapCmd {
cmd := NewStringStructMapCmd(ctx, "smembers", key)
_ = c(ctx, cmd)
Expand Down Expand Up @@ -2144,7 +2144,8 @@ func (c cmdable) ClientKill(ctx context.Context, ipPort string) *StatusCmd {
}

// ClientKillByFilter is new style syntax, while the ClientKill is old
// CLIENT KILL <option> [value] ... <option> [value]
//
// CLIENT KILL <option> [value] ... <option> [value]
func (c cmdable) ClientKillByFilter(ctx context.Context, keys ...string) *IntCmd {
args := make([]interface{}, 2+len(keys))
args[0] = "client"
Expand Down
4 changes: 2 additions & 2 deletions internal/instruments.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
)

var (
// Count of write commands performed
// WritesCounter is a count of write commands performed.
WritesCounter metric.Int64Counter
// Count of new connections
// NewConnectionsCounter is a count of new connections.
NewConnectionsCounter metric.Int64Counter
)

Expand Down
4 changes: 2 additions & 2 deletions redisext/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (OpenTelemetryHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (co
func (OpenTelemetryHook) AfterProcess(ctx context.Context, cmd redis.Cmder) error {
span := trace.SpanFromContext(ctx)
if err := cmd.Err(); err != nil {
internal.RecordError(ctx, err)
_ = internal.RecordError(ctx, err)
}
span.End()
return nil
Expand Down Expand Up @@ -90,7 +90,7 @@ func (OpenTelemetryHook) BeforeProcessPipeline(ctx context.Context, cmds []redis
func (OpenTelemetryHook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error {
span := trace.SpanFromContext(ctx)
if err := cmds[0].Err(); err != nil {
internal.RecordError(ctx, err)
_ = internal.RecordError(ctx, err)
}
span.End()
return nil
Expand Down
44 changes: 22 additions & 22 deletions result.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,127 +2,127 @@ package redis

import "time"

// NewCmdResult returns a Cmd initialised with val and err for testing
// NewCmdResult returns a Cmd initialised with val and err for testing.
func NewCmdResult(val interface{}, err error) *Cmd {
var cmd Cmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewSliceResult returns a SliceCmd initialised with val and err for testing
// NewSliceResult returns a SliceCmd initialised with val and err for testing.
func NewSliceResult(val []interface{}, err error) *SliceCmd {
var cmd SliceCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewStatusResult returns a StatusCmd initialised with val and err for testing
// NewStatusResult returns a StatusCmd initialised with val and err for testing.
func NewStatusResult(val string, err error) *StatusCmd {
var cmd StatusCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewIntResult returns an IntCmd initialised with val and err for testing
// NewIntResult returns an IntCmd initialised with val and err for testing.
func NewIntResult(val int64, err error) *IntCmd {
var cmd IntCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewDurationResult returns a DurationCmd initialised with val and err for testing
// NewDurationResult returns a DurationCmd initialised with val and err for testing.
func NewDurationResult(val time.Duration, err error) *DurationCmd {
var cmd DurationCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewBoolResult returns a BoolCmd initialised with val and err for testing
// NewBoolResult returns a BoolCmd initialised with val and err for testing.
func NewBoolResult(val bool, err error) *BoolCmd {
var cmd BoolCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewStringResult returns a StringCmd initialised with val and err for testing
// NewStringResult returns a StringCmd initialised with val and err for testing.
func NewStringResult(val string, err error) *StringCmd {
var cmd StringCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewFloatResult returns a FloatCmd initialised with val and err for testing
// NewFloatResult returns a FloatCmd initialised with val and err for testing.
func NewFloatResult(val float64, err error) *FloatCmd {
var cmd FloatCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewStringSliceResult returns a StringSliceCmd initialised with val and err for testing
// NewStringSliceResult returns a StringSliceCmd initialised with val and err for testing.
func NewStringSliceResult(val []string, err error) *StringSliceCmd {
var cmd StringSliceCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewBoolSliceResult returns a BoolSliceCmd initialised with val and err for testing
// NewBoolSliceResult returns a BoolSliceCmd initialised with val and err for testing.
func NewBoolSliceResult(val []bool, err error) *BoolSliceCmd {
var cmd BoolSliceCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewStringStringMapResult returns a StringStringMapCmd initialised with val and err for testing
// NewStringStringMapResult returns a StringStringMapCmd initialised with val and err for testing.
func NewStringStringMapResult(val map[string]string, err error) *StringStringMapCmd {
var cmd StringStringMapCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewStringIntMapCmdResult returns a StringIntMapCmd initialised with val and err for testing
// NewStringIntMapCmdResult returns a StringIntMapCmd initialised with val and err for testing.
func NewStringIntMapCmdResult(val map[string]int64, err error) *StringIntMapCmd {
var cmd StringIntMapCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewTimeCmdResult returns a TimeCmd initialised with val and err for testing
// NewTimeCmdResult returns a TimeCmd initialised with val and err for testing.
func NewTimeCmdResult(val time.Time, err error) *TimeCmd {
var cmd TimeCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewZSliceCmdResult returns a ZSliceCmd initialised with val and err for testing
// NewZSliceCmdResult returns a ZSliceCmd initialised with val and err for testing.
func NewZSliceCmdResult(val []Z, err error) *ZSliceCmd {
var cmd ZSliceCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewZWithKeyCmdResult returns a NewZWithKeyCmd initialised with val and err for testing
// NewZWithKeyCmdResult returns a NewZWithKeyCmd initialised with val and err for testing.
func NewZWithKeyCmdResult(val *ZWithKey, err error) *ZWithKeyCmd {
var cmd ZWithKeyCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewScanCmdResult returns a ScanCmd initialised with val and err for testing
// NewScanCmdResult returns a ScanCmd initialised with val and err for testing.
func NewScanCmdResult(keys []string, cursor uint64, err error) *ScanCmd {
var cmd ScanCmd
cmd.page = keys
Expand All @@ -131,47 +131,47 @@ func NewScanCmdResult(keys []string, cursor uint64, err error) *ScanCmd {
return &cmd
}

// NewClusterSlotsCmdResult returns a ClusterSlotsCmd initialised with val and err for testing
// NewClusterSlotsCmdResult returns a ClusterSlotsCmd initialised with val and err for testing.
func NewClusterSlotsCmdResult(val []ClusterSlot, err error) *ClusterSlotsCmd {
var cmd ClusterSlotsCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewGeoLocationCmdResult returns a GeoLocationCmd initialised with val and err for testing
// NewGeoLocationCmdResult returns a GeoLocationCmd initialised with val and err for testing.
func NewGeoLocationCmdResult(val []GeoLocation, err error) *GeoLocationCmd {
var cmd GeoLocationCmd
cmd.locations = val
cmd.SetErr(err)
return &cmd
}

// NewGeoPosCmdResult returns a GeoPosCmd initialised with val and err for testing
// NewGeoPosCmdResult returns a GeoPosCmd initialised with val and err for testing.
func NewGeoPosCmdResult(val []*GeoPos, err error) *GeoPosCmd {
var cmd GeoPosCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewCommandsInfoCmdResult returns a CommandsInfoCmd initialised with val and err for testing
// NewCommandsInfoCmdResult returns a CommandsInfoCmd initialised with val and err for testing.
func NewCommandsInfoCmdResult(val map[string]*CommandInfo, err error) *CommandsInfoCmd {
var cmd CommandsInfoCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewXMessageSliceCmdResult returns a XMessageSliceCmd initialised with val and err for testing
// NewXMessageSliceCmdResult returns a XMessageSliceCmd initialised with val and err for testing.
func NewXMessageSliceCmdResult(val []XMessage, err error) *XMessageSliceCmd {
var cmd XMessageSliceCmd
cmd.val = val
cmd.SetErr(err)
return &cmd
}

// NewXStreamSliceCmdResult returns a XStreamSliceCmd initialised with val and err for testing
// NewXStreamSliceCmdResult returns a XStreamSliceCmd initialised with val and err for testing.
func NewXStreamSliceCmdResult(val []XStream, err error) *XStreamSliceCmd {
var cmd XStreamSliceCmd
cmd.val = val
Expand Down

0 comments on commit 38c87c1

Please sign in to comment.