Skip to content

Plugin for Intellij IDEA to calculate complexity for your code right into the editor. Works for Java and Kotlin

Notifications You must be signed in to change notification settings

LahaLuhem/code-complexity-plugin

 
 

Repository files navigation

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

  • Using IDE built-in plugin system:

    Settings/Preferences > Plugins > Marketplace > Search for "code-complexity-plugin" > Install Plugin

  • Manually:

    Download the latest release and install it manually using Settings/Preferences > Plugins > ⚙️ > Install plugin from disk...

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

  • Update version in gradle.properties
  • Update version and description in CHANGELOG.md
  • Run ./gradlew publishPlugin
  • Push to repo with the proper tag

Plugin based on the IntelliJ Platform Plugin Template.

About

Plugin for Intellij IDEA to calculate complexity for your code right into the editor. Works for Java and Kotlin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 82.2%
  • Java 13.7%
  • Python 3.7%
  • HTML 0.4%