javaintellij-ideatime-complexityintellij-plugincyclomatic-complexity

Cyclomatic Complexity in Intellij


I was working on an assignment today that basically asked us to write a Java program that checks if HTML syntax is valid in a text file. Pretty simple assignment, I did it very quickly, but in doing it so quickly I made it very convoluted (lots of loops and if statements). I know I can make it a lot simpler, and I will before turning it in, but Amid my procrastination, I started downloading plugins and seeing what information they could give me.

I downloaded two in particular that I'm curious about - CodeMetrics and MetricsReloaded. I was wondering what exactly these numbers that it generates correlate to. I saw one post that was semi-similar, and I read it as well as the linked articles, but I'm still having some trouble understanding a couple of things. Namely, what the first two columns (CogC and ev(G)), as well as some more clarification on the other two (iv(G) and v(G)), mean.

MetricsReloaded Method Metrics:

MetricsReloaded Method Metrics

MetricsReloaded Class Metrics:

MetricsReloaded Class Metrics

These previous numbers are from MetricsReloaded, but this other application, CodeMetrics, which also calculates cyclomatic complexity gives slightly different numbers. I was wondering how these numbers correlate and if someone could just give a brief general explanation of all this.

CodeMetrics Analysis Results:

CodeMetrics Analysis Results

My final question is about time complexity. My understanding of Cyclomatic complexity is that it is the number of possible paths of execution and that it is determined by the number of conditionals and how they are nested. It doesn't seem like it would, but does this correlate in any way to time complexity? And if so, is there a conversion between them that can be easily done? If not, is there a way in either of these plug-ins (or any other in IntelliJ) that can automate time complexity calculations?


Solution

  • To answer you first question here is the definition of those metrics in question

    Sources:

    https://www.sciencedirect.com/science/article/abs/pii/S0950584918301903 http://www.mccabe.com/iq_research_metrics.htm