nikolaikopernik / code-complexity-plugin

Plugin for Intellij IDEA to calculate complexity for your code right into the editor. Works for Java and Kotlin
23 stars 5 forks source link

Code Complexity plugin for IDEA

Build Version Downloads

This plugin calculates code complexity metric right in the editor and shows the complexity in the hint next to the method/class. It's based on the Cognitive Complexity metric proposed by G. Ann Campbell in Cognitive Complexity - A new way of measuring understandability.

Works with Java, Kotlin, and Python.


Example hints

Installation

Score

I chose 8 points as a medium complexity method and use it as 100%. This means that all the methods above 100% are good candidates for splitting/improving. The formula is: percentage = points / 8 * 100

Configuration

You can find plugin configuration under Settings > Tools > Code Complexity


Configuration example

Inspection

There is an inspection added to support checking multiple files in your project. All the supported languages of the plugin also work in inspection. To run the inspection: Search everywhere > Run inspection by Name... > High code complexity

The inspection works only on methods currently and will find all the methods with the very high complexity score.


Configuration example

NOTE: You can enable inspection to work on the fly, but in this case it will do the same as code hints which are already in your editor - it will highlight the methods with the very high complexity score.

Release


Plugin based on the IntelliJ Platform Plugin Template.