Showing 130 of 651 total issues
Method clusterClient.doretry
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (c *clusterClient) doretry(ctx context.Context, cc conn, results *redisresults, retries *connretry, re *retry, mu *sync.Mutex, wg *sync.WaitGroup) {
Method clusterClient.doretrycache
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
func (c *clusterClient) doretrycache(ctx context.Context, cc conn, results *redisresults, retries *connretrycache, re *retrycache, mu *sync.Mutex, wg *sync.WaitGroup) {
Avoid deeply nested control flow statements. Open
Open
if !blocked {
time.Sleep(flushDelay - time.Since(flushStart)) // ref: https://github.com/redis/rueidis/issues/156
}
Function newSchema
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func newSchema(t reflect.Type) schema {
if t.Kind() != reflect.Struct {
panic(fmt.Sprintf("schema %q should be a struct", t))
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
Open
switch record.values[j].string {
case "extra_attributes":
docs[d], _ = record.values[j+1].AsStrMap()
}
Avoid deeply nested control flow statements. Open
Open
goto next
Function _newPipe
has 7 return statements (exceeds 4 allowed). Open
Open
func _newPipe(connFn func() (net.Conn, error), option *ClientOption, r2ps, nobg bool) (p *pipe, err error) {
conn, err := connFn()
if err != nil {
return nil, err
}
Method pipe.DoMulti
has 7 return statements (exceeds 4 allowed). Open
Open
func (p *pipe) DoMulti(ctx context.Context, multi ...Completed) *redisresults {
resp := resultsp.Get(len(multi), len(multi))
if err := ctx.Err(); err != nil {
for i := 0; i < len(resp.s); i++ {
resp.s[i] = newErrResult(err)
Avoid deeply nested control flow statements. Open
Open
} else if v.typ == typeInteger || v.typ == typeNull {
r[k.string] = v.integer
}
Avoid deeply nested control flow statements. Open
Open
if pttl := msg.values[i].integer; pttl >= 0 {
cp.setExpireAt(now.Add(time.Duration(pttl) * time.Millisecond).UnixMilli())
}
Avoid deeply nested control flow statements. Open
Open
if !m.noloop {
<-csc
}
Avoid deeply nested control flow statements. Open
Open
} else if err.IsClusterDown() || err.IsTryAgain() {
mode = RedirectRetry
}
Avoid deeply nested control flow statements. Open
Open
if msg.values[i], err = readNextMessage(p.r); err != nil {
return
}
Avoid deeply nested control flow statements. Open
Open
} else if strings.Contains(re.string, "CLIENT") {
err = fmt.Errorf("%s: %w", re.string, ErrNoCache)
} else if r2 {
continue
}
Avoid deeply nested control flow statements. Open
Open
goto process
Avoid deeply nested control flow statements. Open
Open
select {
case g.ch <- struct{}{}:
default:
}
Method dedicatedClusterClient.DoMulti
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
Open
func (c *dedicatedClusterClient) DoMulti(ctx context.Context, multi ...Completed) (resp []RedisResult) {
if len(multi) == 0 {
return nil
}
slot := chooseSlot(multi)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid deeply nested control flow statements. Open
Open
goto miss1
Avoid deeply nested control flow statements. Open
Open
if delete(kc.cache, e.cmd); len(kc.cache) == 0 {
delete(c.store, kc.key)
}
Avoid deeply nested control flow statements. Open
Open
if pttl := msg.values[ci-1].integer; pttl >= 0 {
cp.setExpireAt(now.Add(time.Duration(pttl) * time.Millisecond).UnixMilli())
}