Showing 635 of 649 total issues
Method pipe.DoMultiCache
has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring. Open
func (p *pipe) DoMultiCache(ctx context.Context, multi ...CacheableTTL) *redisresults {
if p.cache == nil {
commands := make([]Completed, len(multi))
for i, ct := range multi {
commands[i] = Completed(ct.Cmd)
- 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
Builder
has 35 methods (exceeds 20 allowed). Consider refactoring. Open
func (b Builder) Bzmpop() (c Bzmpop) {
c = Bzmpop{cs: get(), ks: b.ks, cf: int16(blockTag)}
c.cs.s = append(c.cs.s, "BZMPOP")
return c
}
Method pipe._backgroundWrite
has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring. Open
func (p *pipe) _backgroundWrite() (err error) {
var (
ones = make([]Completed, 1)
multi []Completed
ch chan RedisResult
- 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
Method RedisMessage.AsFtSearch
has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring. Open
func (m *RedisMessage) AsFtSearch() (total int64, docs []FtSearchDoc, err error) {
if err = m.Error(); err != nil {
return 0, nil, err
}
if m.IsMap() {
- 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
clusterClient
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
type clusterClient struct {
pslots [16384]conn
rslots []conn
opt *ClientOption
rOpt *ClientOption
Builder
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
func (b Builder) Copy() (c Copy) {
c = Copy{cs: get(), ks: b.ks}
c.cs.s = append(c.cs.s, "COPY")
return c
}
Method pipe.doCacheMGet
has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring. Open
func (p *pipe) doCacheMGet(ctx context.Context, cmd Cacheable, ttl time.Duration) RedisResult {
commands := cmd.Commands()
keys := len(commands) - 1
builder := cmds.NewBuilder(cmds.InitSlot)
result := RedisResult{val: RedisMessage{typ: '*', values: nil}}
- 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
Builder
has 30 methods (exceeds 20 allowed). Consider refactoring. Open
func (b Builder) Asking() (c Asking) {
c = Asking{cs: get(), ks: b.ks}
c.cs.s = append(c.cs.s, "ASKING")
return c
}
Method clusterClient._refresh
has 115 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *clusterClient) _refresh() (err error) {
c.mu.RLock()
results := make(chan clusterslots, len(c.conns))
pending := make([]conn, 0, len(c.conns))
if c.aws {
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (c *clusterClient) doretrycache(ctx context.Context, cc conn, results *redisresults, retries *connretrycache, re *retrycache, mu *sync.Mutex, wg *sync.WaitGroup) {
if len(re.commands) != 0 {
resps := cc.DoMultiCache(ctx, re.commands...)
c.resultcachefn(ctx, results, retries, mu, cc, re.cIndexes, re.commands, resps.s)
resultsp.Put(resps)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 265.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
func (c *clusterClient) doretry(ctx context.Context, cc conn, results *redisresults, retries *connretry, re *retry, mu *sync.Mutex, wg *sync.WaitGroup) {
if len(re.commands) != 0 {
resps := cc.DoMulti(ctx, re.commands...)
c.doresultfn(ctx, results, retries, mu, cc, re.cIndexes, re.commands, resps.s)
resultsp.Put(resps)
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 265.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
FtSearchQuery
has 26 methods (exceeds 20 allowed). Consider refactoring. Open
type FtSearchQuery Incomplete
Method clusterClient._pickMulti
has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring. Open
func (c *clusterClient) _pickMulti(multi []Completed) (retries *connretry, last uint16, toReplica bool) {
last = cmds.InitSlot
init := false
for _, cmd := range 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
Builder
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
func (b Builder) FtAggregate() (c FtAggregate) {
c = FtAggregate{cs: get(), ks: b.ks, cf: int16(readonly)}
c.cs.s = append(c.cs.s, "FT.AGGREGATE")
return c
}
pipe
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
type pipe struct {
conn net.Conn
error atomic.Value
clhks atomic.Value // closed hook, invoked after the conn is closed
pshks atomic.Value // pubsub hook, registered by the SetPubSubHooks
FtSearchNocontent
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
type FtSearchNocontent Incomplete
Builder
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
func (b Builder) JsonArrappend() (c JsonArrappend) {
c = JsonArrappend{cs: get(), ks: b.ks}
c.cs.s = append(c.cs.s, "JSON.ARRAPPEND")
return c
}
mux
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
type mux struct {
init wire
dead wire
clhks atomic.Value
dpool *pool
Method pipe.doCacheMGet
has 92 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *pipe) doCacheMGet(ctx context.Context, cmd Cacheable, ttl time.Duration) RedisResult {
commands := cmd.Commands()
keys := len(commands) - 1
builder := cmds.NewBuilder(cmds.InitSlot)
result := RedisResult{val: RedisMessage{typ: '*', values: nil}}
FtSearchVerbatim
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
type FtSearchVerbatim Incomplete