-
…in reply to @getify
getify An independent path isn't necessarily different lines of code, it's just whenever the processor has to branch. The complexity (M) is given by Edges - Nodes + 2, where a node is a decision path or the start/end. So in this case you have just 4 nodes and 3 edges, for M=3.
-
…in reply to @rockerest
getify So I definitely misspoke earlier about explicitly handling the else cases. Closer study of the definition of cyclomatic complexity tells me that handling them or not, it's about the decision path, which is already passed during the
ifexpression. -
…in reply to @rockerest
getify In fact, the wiki for CC (en.wikipedia.org/wiki/Cyclomatic_complexity#Implications_for_software_testing) explicitly uses this exact example. I simplified the "connected components" part using an equation from above (simple methods always have 1 connected component, e.g. +2) but the image in that section exactly duplicates your graph
