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

Proposal: Median option #54

Open yuonoda opened 2 weeks ago

yuonoda commented 2 weeks ago

Hey, thank you for your providing nice tool ! I would like you to add new option to show median of cyclomatic complexity.

I often meet occasions that a distribution of cyclomatic complexity in my code is highly skewed. For example, a complexity of almost all functions in my repo is around 1. But, a little functions marks 10 to 100 complexity. In such case, average complexity tend to be higher than median or mode, so cannot capture whole trend.

I propose to inplement median option to this command like this,

    -med, -med-short      show the median complexity over all functions;
                          the short option prints the value without a label

This should be helpful for those who meet same issue with me.

Thanks,

fzipp commented 2 weeks ago

I agree that the median is useful. Would you like to implement it and create a pull request?

fzipp commented 3 days ago

Someone created a pull request for a percentile option: #55 This would cover the median as the 50th percentile. You may want to provide your input there as well.