Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should be the range of cyclomatic complexity for JAVA

I want to know that what should be the standard range of cyclomatic complexity?

And does it depends on language or platform or it is common for all?

I am using State of Flow - EclipseMetrics which is a Eclipse plugin calculates various metrics for your code during build cycles and warns you, via the Problems view, of ‘range violations’ for each metric.

like image 479
Nirali Avatar asked Dec 27 '22 01:12

Nirali


2 Answers

As low as possible, just like any other code. Generally it's recommended to keep the cyclomatic complexity below 5.

In reality, that's easier said than done though. Good luck!

like image 76
JREN Avatar answered Dec 28 '22 15:12

JREN


I have refered this link - http://www.javaworld.com/community/node/1005

Cyclocmatic complexity = Number of decision points + 1

The decision points may be your conditional statements like if, if … else, switch , for loop, while loop etc.

The following chart describes the type of the application.

Cyclomatic Complexity lies 1 – 10  To be considered Normal applicatinon

Cyclomatic Complexity lies 11 – 20Moderate application

Cyclomatic Complexity lies 21 – 50Risky application

Cyclomatic Complexity lies more than 50Unstable application

like image 31
Nirali Avatar answered Dec 28 '22 14:12

Nirali