Complexity for one function


(Marie) #1

Hello !

I try to obtain the complexity for one function with SonarQube.

First, I found I had to downgrade my SonarQube version to 6.6 to have the feature “Complexity / function”.

My first question is : Is there a way to have this feature in a more recent version of SonarQube ? I saw it had been removed since the version 6.7.

As seen in this picture, I have a popup “2 functions have a complexity around 30”.

My second question is : Is there a way to know which particular functions have a complexity around 30 ? When I click on a file below the popup, I don’t see any complexity for each function.

Thank you for your answer and have a good day ! :slight_smile:


How to get method and class complexity
(Nicolas Bontoux) #2

Hi Marie,

It is not possible to navigate directly to the individual functions that have a specific complexity as shown per columns. SonarQube only tracks the overall distribution, it does not maintain a mapping of which functions have which complexity. Two notes on top of this:

  • if you wish to track functions that have a complexity too high, then you should use the dedicated rules for that purpose (search for complexity on rules page). It will trigger automatically in case of violation, and you’ll then benefit from the full feature-set of Issue Tracking and Issue navigation.
  • the specific distribution as you see it in v5.6.x is indeed no longer rendered in v6.7.x LTS. That is because previous point should be favoured to track abnormal complexity, and overall measure reporting has evolved into more interactive visualisations (refreshed Measures page).