I was trying to find the cyclomatic complexity (CC) of a Java program and i am having a few problems. i tried generating CCby using the below code...
but i don't think this is right... because i am not taking into account the nested ifs and for loops and i feel not all parameters have been added. How exactly are the nested if's and for's should be considered...
Also i need the average CC of the program... now is the average complexity (total CC / Number of methods)? when i calculated the avg CC of the below attached Java file i found it to be 2.26 but when i generated it through a tool i got the value as 1.6. Also do method calls come into account for CC
can anyone please tell me how exactly to deal with this??
Joined: Dec 07, 2010
The Java File that i tested for CC is given below...
Not an answer to your question, but be aware that the code does not seem to ignore keywords that occur in comments and string literals. You're most likely better off using a proper Java source code parser, like those that are available for Antlr, JavaCC and SableCC.
Also note that "foreach", "or", "and" and "xor" are not Java keywords.
Ping & DNS - updated with new look and Ping home screen widget