Replies: 4 comments 5 replies
-
So the number itself is just a cheaply computed version of cyclomatic complexity https://en.wikipedia.org/wiki/Cyclomatic_complexity I say cheaply because it's just a count of any branch condition inside the code. Whereas the real cyclomatic complexity value has more too it, but requires a full language parser to calculate. A while ago I did do a large scale run to see if I could get some idea on languages and counts https://boyter.org/posts/an-informal-survey-of-10-million-github-bitbucket-gitlab-projects/ with the idea of being able to write some sort of guide about what the complexity means. I am still yet to get around to that... one of these days. For now however, I think it's fairly safe to say that files with lower complexity should mean less technical debt. For example, I personally use the number when looking at any project to identify where the most problematic files might be. Consider the following,
Give then above I am able to infer that the main.go file has a lot going on in it. Its where I would start looking were I tasked with maintaining this application or if I were trying to improve it or add tests. However you can also supply the
Perhaps this blog post I wrote might help? https://boyter.org/posts/why-count-lines-of-code/ In it I analysed a project I was not familiar with using In short though, the complexity as a total is not very useful, unless comparing to a similar project, or the same project over time. Per file it can be useful to identify where problems in a project might be. If you want to use this to manage technical debt, you could use the number to identify files that potentially should be broken down and then track that this occurs with its complexity coming down over time. |
Beta Was this translation helpful? Give feedback.
-
@boyter if we are in the subject on complexity, there are other resources that provides a template for it https://github.com/priv-kweihmann/multimetric
Some not included are
|
Beta Was this translation helpful? Give feedback.
-
There are also https://github.com/mxmssh/IDAmetrics and this defunct one https://github.com/philbooth/escomplex
|
Beta Was this translation helpful? Give feedback.
-
Do I understand correctly that |
Beta Was this translation helpful? Give feedback.
-
Hi,
I've read the readme about complexity but I'm still unsure what the produced numbers mean?
Is there a guide to the magnitude, thresholds for complexity numbers and what that means for technical debt?
Thanks for the help,
Pat
Beta Was this translation helpful? Give feedback.
All reactions