Showing 8 of 19 total issues
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()
}
Function GeneratePropertiesMap
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
Open
func GeneratePropertiesMap(data interface{}) map[string]string {
properties := map[string]string{}
if data == nil {
return properties
- 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
Function GeneratePropertiesMap
has 55 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func GeneratePropertiesMap(data interface{}) map[string]string {
properties := map[string]string{}
if data == nil {
return properties
Method Filter.UnmarshalYAML
has 53 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (f *Filter) UnmarshalYAML(unmarshal func(interface{}) error) error {
var value string
if unmarshal(&value) == nil {
f.Type = Exact
Method Filter.Match
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (f *Filter) Match(o string) (bool, error) { //nolint:gocyclo
switch f.Type {
case Empty, Exact:
return f.Value == o, nil
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() {