ekristen/libnuke

View on GitHub

Showing 8 of 19 total issues

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

    Function GeneratePropertiesMap has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
    Open

    func GeneratePropertiesMap(data interface{}) map[string]string {
        properties := map[string]string{}
    
        if data == nil {
            return properties
    Severity: Minor
    Found in pkg/docs/generate.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

    Function GeneratePropertiesMap has 55 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func GeneratePropertiesMap(data interface{}) map[string]string {
        properties := map[string]string{}
    
        if data == nil {
            return properties
    Severity: Minor
    Found in pkg/docs/generate.go - About 1 hr to fix

      Method Filter.UnmarshalYAML has 53 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func (f *Filter) UnmarshalYAML(unmarshal func(interface{}) error) error {
          var value string
      
          if unmarshal(&value) == nil {
              f.Type = Exact
      Severity: Minor
      Found in pkg/filter/filter.go - About 1 hr to fix

        Method Filter.Match has 52 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (f *Filter) Match(o string) (bool, error) { //nolint:gocyclo
            switch f.Type {
            case Empty, Exact:
                return f.Value == o, nil
        
        
        Severity: Minor
        Found in pkg/filter/filter.go - About 1 hr 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
              Severity
              Category
              Status
              Source
              Language