So pretty much I was taught to work out the cyclomatic complexity like this site does But then recently I found this thing that says Cyclomatic Complexity = ( 1 + ifs + loops + cases ). Are they the same? is the thing I read perfect for every case? As I'm wondering whether it would miss out on something or doesn't take something into account when calculating? From what I understand it seems fine but it just feels a bit simple compared to drawing out everything.
Also if I have a loop such as
while (a==b && c>d) {
}
would I say there is 1 loop there (comp = 1 loop+1) or would I say there is 3 (1 loop +1 test+1 test+1) due to the while a==b and the c>d test parts. and how does that compare to say just
while(a>b) {
}
as I would assume that would have just 1 loop so (comp = 1 loop +1) I would also assume it would be the exact same as a FOR loop in terms of complexity.
as
for(int i =0; i<12; i++){
}
it has just the single loop.
Lastly if I have something like code, while loop with no if statements or anything then end code.
If I drew the paths do I just have one path doing code>loop>endcode. Or do I have two paths being:
1) code>loop>endcode
2) code>endcode Imagine that loop is the FOR loop I wrote above for example.
Apologies for all the questions, it seems to be loops in particular I'm super confused with.