pkg/types/properties.go
Method Properties.SetFromStruct
has a Cognitive Complexity of 94 (exceeds 20 allowed). Consider refactoring. Open
Open
func (p Properties) SetFromStruct(data interface{}) Properties { //nolint:funlen,gocyclo
v := reflect.ValueOf(data)
if v.Kind() == reflect.Ptr {
v = v.Elem()
}
- 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 Properties.SetFromStruct
has 121 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p Properties) SetFromStruct(data interface{}) Properties { //nolint:funlen,gocyclo
v := reflect.ValueOf(data)
if v.Kind() == reflect.Ptr {
v = v.Elem()
}
Avoid deeply nested control flow statements. Wontfix
Wontfix
if keyField.IsValid() && valueField.IsValid() {
p.SetTagWithPrefix(prefix, &[]string{keyField.Interface().(string)}[0], valueField.Interface())
}
Avoid deeply nested control flow statements. Open
Open
if keyFieldName != "" {
keyField = sliceValueV.FieldByName(keyFieldName)
} else {
keyField = sliceValueV.FieldByName("Key")
if !keyField.IsValid() {
Avoid deeply nested control flow statements. Open
Open
if valueFieldName != "" {
valueField = sliceValueV.FieldByName(valueFieldName)
} else {
valueField = sliceValueV.FieldByName("Value")
if !valueField.IsValid() {
Avoid deeply nested control flow statements. Wontfix
Wontfix
if valueField.Kind() == reflect.Ptr {
valueField = valueField.Elem()
}
Avoid deeply nested control flow statements. Wontfix
Wontfix
if keyField.Kind() == reflect.Ptr {
keyField = keyField.Elem()
}
Method Properties.Set
has 6 return statements (exceeds 4 allowed). Wontfix
Wontfix
func (p Properties) Set(key string, value interface{}) Properties { //nolint:gocyclo
if value == nil {
return p
}
Method Properties.Equals
has 6 return statements (exceeds 4 allowed). Wontfix
Wontfix
func (p Properties) Equals(o Properties) bool {
if p == nil && o == nil {
return true
}