SonarQube fails on comment % while calculated ratio is >26%

1.4k Views Asked by At

I have been using sonar for over 4 years for Java projects we have created.


Currently, we want to fail the build if some metrics cannot be met. Thus, I installed Build Breaker plugin and re-run the build cycle, without any issue. Then I modified quality gates to contain "'Comments (%)' rule to for 'is less than' check of '20' ( threshold for warning), '10'( threshold for error) " as attached in:

Quality Gates Screenshot

However, after those definitions the projects failed to build. Although all files seem to have enough comment (from 28 % to 77 %) , as in image below,

Percent of comment ratio per java file

While in main screen it is shown as 0%

Summary screen

I could not find any log, comment or information on how this can happen (in sonar.log or mvn -X ) and as far I searched , no one encountered this issue.

Did anyone encountered this problem, or have any idea why this can occur? My SonarQube version is 5.6.7, Build Breaker version is 2.2 (downloaded from github), maven version is 3.0.5 and JDK 8.

1

There are 1 best solutions below

2
On BEST ANSWER

When defining your Quality Gate, you selected the option "over leak period". So what counts the variation of the % of comments in your current leak period, which is the version 1.4.1.

What you see in the screenshot with the perc. of comments per file is the absolute measure.

You might want to uncheck the option "over leak period".

Note that the way measures are displayed was improved in later versions of SonarQube.