Quick way to get a Complexity value in Intellij

One of the devs here got flagged that complexity for some method was > 15.

He refactored and the alert ‘went away.’ He wanted to know how much the metric went down, though.

So if there an easy way to get Sonar’s complexity metric for a method from within Intellij?


Hi @johng42

There is no such feature currently. I suggest you open (or move) a thread in the “request a feature” category so that we could monitor how much interest people have for this idea.

Hello @johng42,

I understand your request and at the same I wonder what would you do with this metric if it was available. You will know the complexity of the method (that will be lower <= 15) and then what would be the next action?


The intent would be to set a quality gate - if complexity > threshold, then fail. This would force refactors to lower than the threshold.

The immediate feedback I would want is something like:

  1. Ah, shoot, I am modifying a method with a complexity of 35
  2. Sonar failed my build
  3. I look at the method, extract some code and I want to know if the now-refactored method has a complexity < threshold.
    a. I could invoke sonar, but that interrupts my workflow from within IntelliJ
    b. I’d rather right click / analyze / click some widget that reports - "The complexity of this method is X’

Make sense? The information is available in a few other locations. I don’t want my attention to be diverted from the IDE since that is where I will need to go to fix the error anyway.

1 Like

Thanks for the clarification. That’s really clear to me now.