rueian/rueidis

View on GitHub

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)
Severity: Minor
Found in pipe.go - About 4 hrs to fix

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
}
Severity: Minor
Found in internal/cmds/gen_sorted_set.go - About 4 hrs to fix

    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
    Severity: Minor
    Found in pipe.go - About 4 hrs to fix

    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() {
    Severity: Minor
    Found in message.go - About 4 hrs to fix

    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
    Severity: Minor
    Found in cluster.go - About 4 hrs to fix

      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
      }
      Severity: Minor
      Found in internal/cmds/gen_generic.go - About 4 hrs to fix

        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}}
        Severity: Minor
        Found in pipe.go - About 3 hrs to fix

        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
        }
        Severity: Minor
        Found in internal/cmds/gen_cluster.go - About 3 hrs to fix

          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 {
          Severity: Major
          Found in cluster.go - About 3 hrs to fix

            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)
            Severity: Major
            Found in cluster.go and 1 other location - About 3 hrs to fix
            cluster.go on lines 652..667

            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

            Further Reading

            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)
            Severity: Major
            Found in cluster.go and 1 other location - About 3 hrs to fix
            cluster.go on lines 932..947

            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

            Further Reading

            FtSearchQuery has 26 methods (exceeds 20 allowed). Consider refactoring.
            Open

            type FtSearchQuery Incomplete
            Severity: Minor
            Found in internal/cmds/gen_search.go - About 3 hrs to fix

              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 {
              Severity: Minor
              Found in cluster.go - About 2 hrs to fix

              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
              }
              Severity: Minor
              Found in internal/cmds/gen_search.go - About 2 hrs to fix

                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
                Severity: Minor
                Found in pipe.go - About 2 hrs to fix

                  FtSearchNocontent has 25 methods (exceeds 20 allowed). Consider refactoring.
                  Open

                  type FtSearchNocontent Incomplete
                  Severity: Minor
                  Found in internal/cmds/gen_search.go - About 2 hrs to fix

                    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
                    }
                    Severity: Minor
                    Found in internal/cmds/gen_json.go - About 2 hrs to fix

                      mux has 25 methods (exceeds 20 allowed). Consider refactoring.
                      Open

                      type mux struct {
                          init   wire
                          dead   wire
                          clhks  atomic.Value
                          dpool  *pool
                      Severity: Minor
                      Found in mux.go - About 2 hrs to fix

                        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}}
                        Severity: Major
                        Found in pipe.go - About 2 hrs to fix

                          FtSearchVerbatim has 24 methods (exceeds 20 allowed). Consider refactoring.
                          Open

                          type FtSearchVerbatim Incomplete
                          Severity: Minor
                          Found in internal/cmds/gen_search.go - About 2 hrs to fix
                            Severity
                            Category
                            Status
                            Source
                            Language