therealbill/libredis

View on GitHub

Showing 36 of 68 total issues

Function GetAllInfo has a Cognitive Complexity of 90 (exceeds 20 allowed). Consider refactoring.
Open

func GetAllInfo(infostring string) (info structures.RedisInfoAll) {
    allmap := BuildAllInfoMap(infostring)
    var alldata structures.RedisInfoAll
    all := reflect.ValueOf(&alldata).Elem()
    for i := 0; i < all.NumField(); i++ {
Severity: Minor
Found in info/methods.go - About 1 day 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

File redis.go has 684 lines of code (exceeds 500 allowed). Consider refactoring.
Open

// Package libredis/client is a redis client with full features
//
// It is written in and for Go
// Protocol Specification: http://redis.io/topics/protocol.
//
Severity: Minor
Found in client/redis.go - About 6 hrs to fix

    Redis has 31 methods (exceeds 20 allowed). Consider refactoring.
    Open

    func (r *Redis) BgRewriteAof() error {
        _, err := r.ExecuteCommand("BGREWRITEAOF")
        return err
    }
    Severity: Minor
    Found in client/server.go - About 3 hrs to fix

      Method Redis.dialConnection has a Cognitive Complexity of 37 (exceeds 20 allowed). Consider refactoring.
      Open

      func (r *Redis) dialConnection() (*connection, error) {
          var conn net.Conn
          ipconn, err := net.DialTimeout(r.network, r.address, r.timeout)
          if err != nil {
              return nil, err
      Severity: Minor
      Found in client/redis.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

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

      func (r *Redis) Append(key, value string) (int64, error) {
          rp, err := r.ExecuteCommand("APPEND", key, value)
          if err != nil {
              return 0, err
          }
      Severity: Minor
      Found in client/strings.go - About 2 hrs to fix

        Redis has 21 methods (exceeds 20 allowed). Consider refactoring.
        Open

        func (r *Redis) ZAdd(key string, score float64, val string) (int64, error) {
            rp, err := r.ExecuteCommand("ZADD", key, score, val)
            if err != nil {
                return 0, err
            }
        Severity: Minor
        Found in client/sorted_sets.go - About 2 hrs to fix

          Function GetAllInfo has 77 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func GetAllInfo(infostring string) (info structures.RedisInfoAll) {
              allmap := BuildAllInfoMap(infostring)
              var alldata structures.RedisInfoAll
              all := reflect.ValueOf(&alldata).Elem()
              for i := 0; i < all.NumField(); i++ {
          Severity: Major
          Found in info/methods.go - About 2 hrs to fix

            Method PubSub.Receive has 65 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (p *PubSub) Receive() ([]string, error) {
                rp, err := p.conn.RecvReply()
                if err != nil {
                    return nil, err
                }
            Severity: Minor
            Found in client/pubsub.go - About 1 hr to fix

              Method connection.RecvReply has 65 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (c *connection) RecvReply() (*Reply, error) {
                  line, err := c.Reader.ReadBytes('\n')
                  if err != nil {
                      return nil, err
                  }
              Severity: Minor
              Found in client/redis.go - About 1 hr to fix

                Method Redis.dialConnection has 65 lines of code (exceeds 50 allowed). Consider refactoring.
                Open

                func (r *Redis) dialConnection() (*connection, error) {
                    var conn net.Conn
                    ipconn, err := net.DialTimeout(r.network, r.address, r.timeout)
                    if err != nil {
                        return nil, err
                Severity: Minor
                Found in client/redis.go - About 1 hr to fix

                  Method Redis.buildMasterInfoStruct has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
                  Open

                  func (r *Redis) buildMasterInfoStruct(info map[string]string) (master structures.MasterInfo, err error) {
                      s := reflect.ValueOf(&master).Elem()
                      typeOfT := s.Type()
                      for i := 0; i < s.NumField(); i++ {
                          p := typeOfT.Field(i)
                  Severity: Minor
                  Found in client/sentinel.go - About 1 hr 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 PubSub.Receive has 16 return statements (exceeds 4 allowed).
                  Open

                  func (p *PubSub) Receive() ([]string, error) {
                      rp, err := p.conn.RecvReply()
                      if err != nil {
                          return nil, err
                      }
                  Severity: Major
                  Found in client/pubsub.go - About 1 hr to fix

                    Method PubSub.Receive has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (p *PubSub) Receive() ([]string, error) {
                        rp, err := p.conn.RecvReply()
                        if err != nil {
                            return nil, err
                        }
                    Severity: Minor
                    Found in client/pubsub.go - About 1 hr 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 connection.RecvReply has 12 return statements (exceeds 4 allowed).
                    Open

                    func (c *connection) RecvReply() (*Reply, error) {
                        line, err := c.Reader.ReadBytes('\n')
                        if err != nil {
                            return nil, err
                        }
                    Severity: Major
                    Found in client/redis.go - About 1 hr to fix

                      Method Redis.dialConnection has 10 return statements (exceeds 4 allowed).
                      Open

                      func (r *Redis) dialConnection() (*connection, error) {
                          var conn net.Conn
                          ipconn, err := net.DialTimeout(r.network, r.address, r.timeout)
                          if err != nil {
                              return nil, err
                      Severity: Major
                      Found in client/redis.go - About 1 hr to fix

                        Method Redis.ExecuteCommand has 10 return statements (exceeds 4 allowed).
                        Open

                        func (r *Redis) ExecuteCommand(args ...interface{}) (*Reply, error) {
                            c, err := r.pool.Get()
                            deadline := time.Now().Add(r.timeout)
                            c.Conn.SetDeadline(deadline)
                            if err != nil {
                        Severity: Major
                        Found in client/redis.go - About 1 hr to fix

                          Method Redis.buildSlaveInfoStruct has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func (r *Redis) buildSlaveInfoStruct(info map[string]string) (master structures.SlaveInfo, err error) {
                              s := reflect.ValueOf(&master).Elem()
                              typeOfT := s.Type()
                              for i := 0; i < s.NumField(); i++ {
                                  p := typeOfT.Field(i)
                          Severity: Minor
                          Found in client/sentinel.go - About 55 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

                          Method Redis.buildSentinelInfoStruct has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
                          Open

                          func (r *Redis) buildSentinelInfoStruct(info map[string]string) (sentinel structures.SentinelInfo, err error) {
                              s := reflect.ValueOf(&sentinel).Elem()
                              typeOfT := s.Type()
                              for i := 0; i < s.NumField(); i++ {
                                  p := typeOfT.Field(i)
                          Severity: Minor
                          Found in client/sentinel.go - About 55 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

                          Method Redis.SlowLogGet has 9 return statements (exceeds 4 allowed).
                          Open

                          func (r *Redis) SlowLogGet(n int64) ([]*SlowLog, error) {
                              rp, err := r.ExecuteCommand("SLOWLOG", "GET", n)
                              if err != nil {
                                  return nil, err
                              }
                          Severity: Major
                          Found in client/server.go - About 55 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                            if err != nil {
                                                return nil, err
                                            }
                            Severity: Major
                            Found in client/redis.go - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language