Are there any tools available for Java that can automagically determine the cyclomatic complexity of given Java code? I have sought out tools online, and have yet to find one.

有帮助吗?

解决方案

I use Sonar (my preferred method). There are plugins to "automagically" generate the report at build time (i.e. ANT/Maven, etc...).

Another related post on how to show the CC on the dashboard: how to list methods with most cyclomatic complexity

One other tool I've used in the past is corbetura. You have to have good unit tests though and finding the quantitative analysis for CC is a little tricky.

其他提示

One of the metrics produced by Sonar is Cyclomatic Complexity.
I believe it also has an Eclipse plugin (but I haven't managed to find it yet)

AgitarOne from Agitar Technologies (http://www.agitar.com/solutions/products/agitarone.html) calculates cyclomatic complexity in their dashboard report and with their code rules plugin in Eclipse. Note also that McCabe IQ from McCabe Software (http://www.mccabe.com), a sister company of Agitar Technologies, also calculates cyclomatic complexity (aka McCabe complexity) for Java and has an Eclipse plugin for project setup.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top