ekristen/libnuke

View on GitHub
pkg/types/properties.go

Summary

Maintainability
D
2 days
Test Coverage
A
100%

Method Properties.SetFromStruct has a Cognitive Complexity of 94 (exceeds 20 allowed). Consider refactoring.
Open

func (p Properties) SetFromStruct(data interface{}) Properties { //nolint:funlen,gocyclo
    v := reflect.ValueOf(data)
    if v.Kind() == reflect.Ptr {
        v = v.Elem()
    }
Severity: Minor
Found in pkg/types/properties.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

Method Properties.SetFromStruct has 121 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (p Properties) SetFromStruct(data interface{}) Properties { //nolint:funlen,gocyclo
    v := reflect.ValueOf(data)
    if v.Kind() == reflect.Ptr {
        v = v.Elem()
    }
Severity: Major
Found in pkg/types/properties.go - About 3 hrs to fix

    Avoid deeply nested control flow statements.
    Wontfix

                        if keyField.IsValid() && valueField.IsValid() {
                            p.SetTagWithPrefix(prefix, &[]string{keyField.Interface().(string)}[0], valueField.Interface())
                        }
    Severity: Major
    Found in pkg/types/properties.go - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if keyFieldName != "" {
                              keyField = sliceValueV.FieldByName(keyFieldName)
                          } else {
                              keyField = sliceValueV.FieldByName("Key")
                              if !keyField.IsValid() {
      Severity: Major
      Found in pkg/types/properties.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if valueFieldName != "" {
                                valueField = sliceValueV.FieldByName(valueFieldName)
                            } else {
                                valueField = sliceValueV.FieldByName("Value")
                                if !valueField.IsValid() {
        Severity: Major
        Found in pkg/types/properties.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Wontfix

                              if valueField.Kind() == reflect.Ptr {
                                  valueField = valueField.Elem()
                              }
          Severity: Major
          Found in pkg/types/properties.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Wontfix

                                if keyField.Kind() == reflect.Ptr {
                                    keyField = keyField.Elem()
                                }
            Severity: Major
            Found in pkg/types/properties.go - About 45 mins to fix

              Method Properties.Set has 6 return statements (exceeds 4 allowed).
              Wontfix

              func (p Properties) Set(key string, value interface{}) Properties { //nolint:gocyclo
                  if value == nil {
                      return p
                  }
              
              
              Severity: Major
              Found in pkg/types/properties.go - About 40 mins to fix

                Method Properties.Equals has 6 return statements (exceeds 4 allowed).
                Wontfix

                func (p Properties) Equals(o Properties) bool {
                    if p == nil && o == nil {
                        return true
                    }
                
                
                Severity: Major
                Found in pkg/types/properties.go - About 40 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status