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++ {
- 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
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.
//
Redis
has 31 methods (exceeds 20 allowed). Consider refactoring. Open
func (r *Redis) BgRewriteAof() error {
_, err := r.ExecuteCommand("BGREWRITEAOF")
return err
}
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
- 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
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
}
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
}
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++ {
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
}
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
}
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
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)
- 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 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
}
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
}
- 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 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
}
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
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 {
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)
- 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 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)
- 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 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
}
Avoid deeply nested control flow statements. Open
if err != nil {
return nil, err
}