Home » Android » How to check code cyclomatic complexity in Android studio?

How to check code cyclomatic complexity in Android studio?

Posted by: admin May 14, 2020 Leave a comment

Questions:

How to check code cyclomatic complexity in Android Studio?
Is there any plugin available for Android Studio to check code complexity?

How to&Answers:

There is plugin available named Metrics Reloaded . Which gives your code complexity in levels.

Answer:

Go to Files -> Settings -> Plugins in Android Studio
Type “Metrics Reloaded” in the search bar and install the plugin
Click on Apply
Restart the Android Studio

Now open your source file and right click on it.
Go to Analyze -> Calculate Metrics
In the window, select metrics scope as “current file” and metrics profile as “Complexity Metrics” and Click on “Ok”.

Results will be displayed after clicking OK.
v(G) is the cyclometric complexity
ev(G) is the essential cyclometric complexity
iv(G) is the Module Design Complexity Metric

Answer:

I know it is an old question, but you can check the cyclomatic complexity code in Android studio with the plugin CodeMR.

CodeMR is a software quality and static code analysis tool for Java, Kotlin and Scala projects.

You can also create different HTML reports for the project and export many object-oriented metrics for packages, classes, and methods.

With Community Edition you can extract up to 50 source files and 60 classes. For analyzing more files, you can download a trial license or buy a license from CodeMR website.