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

Allow complex functions if they have documentation #29

Closed ammario closed 3 years ago

ammario commented 4 years ago

It would be nice if gocycle had an option that let complex functions pass as long as they had a doc comment.

If this sounds good, I'm happy to implement it.

fzipp commented 3 years ago

Doc comments (above the function) usually describe the purpose and contract of a function, not its implementation details.

Comments describing the implementation details would be inside the function. Weighing these against the cyclomatic complexity is outside the scope of this project. I think gocyclo should do only one thing and do it well - that is, calculating cyclomatic complexity.

If you want to exclude individual functions from the output, because their complexity is justified, it is now possible with the //gocyclo:ignore directive.