McCabe's Cyclomatic Complexity is designed to measure distinct code paths as described in the two links you have listed. Most people will lay out graphs like the ones in the examples and the one you posted in order to calculate it manually through visualization. When you base the calculation off the interpretation of a visual graph, it requires you to generate the flowchart in order to do the calculation, but the ultimate goal is still to calculate logical pathways. Toad, instead, parses the code to count the individual logical pathways in the code. From Toad's perspective, it sees the following in your code:
- A unique entry point and path
- A divergence defined by the first IF statement creating two distinct pathways
- A divergence in the second pathway with another IF statement that creates two additional pathways.
From that perspective, it calculates one pathway for the overall program, two pathways for the first IF statement, followed by an additional two pathways for the second statement. That produces a total of 5 local pathways. It could be argued that it could be reduced to four (or even three) based on the interpretation of the visual graph. In that sense, perhaps it could be revisited to see if it could tweaked a bit; however, the overall goal of this metric is to keep the McCabe level low (generally a value of 10 or lower). In that sense, the calculated metric by Toad I believe still provides valuable information for the overall goal.
That being said, I'll add an item to revisit this calculation to see if there are ways it can be further tweaked in the future.
Thanks for letting us know about this,