fzipp / gocyclo

Calculate cyclomatic complexities of functions in Go source code.
BSD 3-Clause "New" or "Revised" License
1.33k stars 81 forks source link

Provide a switch to better fit golang #36

Closed paocalvi closed 2 years ago

paocalvi commented 3 years ago

Not just an issue, but it would be nice to have a switch to avoid counting constructs clearly related to mere error checking and returning, for example IF block with less that 3/4 lines testing just err != nil could be not counted in complexity. ES: if err != nil { log....... return nil,err // or return fmt.Errorf("sfsdfsdf %w", err) }

fzipp commented 2 years ago

I don't see this in the scope for this project. Gocyclo is only concerned with cyclomatic complexity / the McCabe metric, which is defined as the maximum number of linearly independent paths of a function, and also specifies the minimum number of test cases required to cover every path of a function. Error paths should be part of that. Rather than make up a new metric you could adjust the limit for your code style.