Showing 635 of 649 total issues
Builder
has 24 methods (exceeds 20 allowed). Consider refactoring. Open
func (b Builder) Auth() (c Auth) {
c = Auth{cs: get(), ks: b.ks}
c.cs.s = append(c.cs.s, "AUTH")
return c
}
Method pipe.DoMultiStream
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring. Open
func (p *pipe) DoMultiStream(ctx context.Context, pool *pool, multi ...Completed) MultiRedisResultStream {
for _, cmd := range multi {
cmds.CompletedCS(cmd).Verify()
}
- 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 23 methods (exceeds 20 allowed). Consider refactoring. Open
func (b Builder) Xack() (c Xack) {
c = Xack{cs: get(), ks: b.ks}
c.cs.s = append(c.cs.s, "XACK")
return c
}
FtSearchNostopwords
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
type FtSearchNostopwords Incomplete
Method locker.try
has 84 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (m *locker) try(ctx context.Context, cancel context.CancelFunc, name string, g *gate) context.CancelFunc {
var err error
val := random()
deadline := time.Now().Add(m.validity)
FtSearchWithscores
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
type FtSearchWithscores Incomplete
Builder
has 22 methods (exceeds 20 allowed). Consider refactoring. Open
func (b Builder) Blmove() (c Blmove) {
c = Blmove{cs: get(), ks: b.ks, cf: int16(blockTag)}
c.cs.s = append(c.cs.s, "BLMOVE")
return c
}
Method lru.Flights
has 82 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *lru) Flights(now time.Time, multi []CacheableTTL, results []RedisResult, entries map[int]CacheEntry) (missed []int) {
var moves []*list.Element
c.mu.RLock()
for i, ct := range multi {
File gen_cluster.go
has 507 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Code generated DO NOT EDIT
package cmds
import "strconv"
Builder
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
func (b Builder) Append() (c Append) {
c = Append{cs: get(), ks: b.ks}
c.cs.s = append(c.cs.s, "APPEND")
return c
}
FtSearchWithpayloads
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
type FtSearchWithpayloads Incomplete
sentinelClient
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
type sentinelClient struct {
mConn atomic.Value
sConn conn
mOpt *ClientOption
sOpt *ClientOption
TsMrevrangeTotimestamp
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
type TsMrevrangeTotimestamp Incomplete
TsMrangeTotimestamp
has 21 methods (exceeds 20 allowed). Consider refactoring. Open
type TsMrangeTotimestamp Incomplete
Method pipe.DoMultiCache
has 78 lines of code (exceeds 50 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)
File gen_bitmap.go
has 504 lines of code (exceeds 500 allowed). Consider refactoring. Open
// Code generated DO NOT EDIT
package cmds
import "strconv"
Similar blocks of code found in 2 locations. Consider refactoring. Open
if dlOk {
if p.timeout > 0 {
defaultDeadline := time.Now().Add(p.timeout)
if dl.After(defaultDeadline) {
dl = defaultDeadline
- 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 195.
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
if ok {
if p.timeout > 0 {
defaultDeadline := time.Now().Add(p.timeout)
if dl.After(defaultDeadline) {
dl = defaultDeadline
- 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 195.
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
Function ParseURL
has 77 lines of code (exceeds 50 allowed). Consider refactoring. Open
func ParseURL(str string) (opt ClientOption, err error) {
u, err := url.Parse(str)
if err != nil {
return opt, err
}
Method clusterClient._pickMulti
has 73 lines of code (exceeds 50 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 {