rueian/rueidis

View on GitHub

Showing 130 of 651 total issues

Method clusterClient.doretry has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

func (c *clusterClient) doretry(ctx context.Context, cc conn, results *redisresults, retries *connretry, re *retry, mu *sync.Mutex, wg *sync.WaitGroup) {
Severity: Major
Found in cluster.go - About 50 mins to fix

    Method clusterClient.doretrycache has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    func (c *clusterClient) doretrycache(ctx context.Context, cc conn, results *redisresults, retries *connretrycache, re *retrycache, mu *sync.Mutex, wg *sync.WaitGroup) {
    Severity: Major
    Found in cluster.go - About 50 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if !blocked {
                              time.Sleep(flushDelay - time.Since(flushStart)) // ref: https://github.com/redis/rueidis/issues/156
                          }
      Severity: Major
      Found in pipe.go - About 45 mins to fix

        Function newSchema has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
        Open

        func newSchema(t reflect.Type) schema {
            if t.Kind() != reflect.Struct {
                panic(fmt.Sprintf("schema %q should be a struct", t))
            }
        
        
        Severity: Minor
        Found in om/schema.go - About 45 mins 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

        Avoid deeply nested control flow statements.
        Open

                                switch record.values[j].string {
                                case "extra_attributes":
                                    docs[d], _ = record.values[j+1].AsStrMap()
                                }
        Severity: Major
        Found in message.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              goto next
          Severity: Major
          Found in pipe.go - About 45 mins to fix

            Function _newPipe has 7 return statements (exceeds 4 allowed).
            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
                }
            Severity: Major
            Found in pipe.go - About 45 mins to fix

              Method pipe.DoMulti has 7 return statements (exceeds 4 allowed).
              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)
              Severity: Major
              Found in pipe.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                } else if v.typ == typeInteger || v.typ == typeNull {
                                    r[k.string] = v.integer
                                }
                Severity: Major
                Found in message.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if pttl := msg.values[i].integer; pttl >= 0 {
                                          cp.setExpireAt(now.Add(time.Duration(pttl) * time.Millisecond).UnixMilli())
                                      }
                  Severity: Major
                  Found in pipe.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if !m.noloop {
                                                <-csc
                                            }
                    Severity: Major
                    Found in rueidislock/lock.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  } else if err.IsClusterDown() || err.IsTryAgain() {
                                      mode = RedirectRetry
                                  }
                      Severity: Major
                      Found in cluster.go - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                        if msg.values[i], err = readNextMessage(p.r); err != nil {
                                            return
                                        }
                        Severity: Major
                        Found in pipe.go - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              } else if strings.Contains(re.string, "CLIENT") {
                                                  err = fmt.Errorf("%s: %w", re.string, ErrNoCache)
                                              } else if r2 {
                                                  continue
                                              }
                          Severity: Major
                          Found in pipe.go - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                goto process
                            Severity: Major
                            Found in pipe.go - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  select {
                                                  case g.ch <- struct{}{}:
                                                  default:
                                                  }
                              Severity: Major
                              Found in rueidislock/lock.go - About 45 mins to fix

                                Method dedicatedClusterClient.DoMulti has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
                                Open

                                func (c *dedicatedClusterClient) DoMulti(ctx context.Context, multi ...Completed) (resp []RedisResult) {
                                    if len(multi) == 0 {
                                        return nil
                                    }
                                    slot := chooseSlot(multi)
                                Severity: Minor
                                Found in cluster.go - About 45 mins 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

                                Avoid deeply nested control flow statements.
                                Open

                                                    goto miss1
                                Severity: Major
                                Found in lru.go - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                      if delete(kc.cache, e.cmd); len(kc.cache) == 0 {
                                                          delete(c.store, kc.key)
                                                      }
                                  Severity: Major
                                  Found in lru.go - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                                    if pttl := msg.values[ci-1].integer; pttl >= 0 {
                                                        cp.setExpireAt(now.Add(time.Duration(pttl) * time.Millisecond).UnixMilli())
                                                    }
                                    Severity: Major
                                    Found in pipe.go - About 45 mins to fix
                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language