Sonar API gate for duplication return negative value

Hi,

I am using sonarqube *6.7.5, sonar java plugin *5.7 (build 15470)

I analyze one of my maven project and it returns positive value for duplication on sonar dashboard.
But, when I try to get quality gate from API, it return different result with negative value.

Hi @budi_suryadi,

If my understanding is correct, you’ve configured your Quality Gate using the metric Duplicated Lines (%), and you’ve checked the On New Code checkbox.
This can lead to such negative values, because it’s doing a diff between current value and value found in the leak.
So if the Duplicated Lines (%) measure decreased between 2 analysis, you’ll get a negative measure.

You should instead use the Duplicated Lines on New Code (%) metric, this will be a far more accurate result !

Regards,
Julien Lancelot

1 Like

Hi @julienlancelot

I am currently using Duplicated Lines on New Code (%) metric, but It doesn’t return the metric.

Here a picture of my quality gate and result of Quality Gate getStatus API

Why is it not returning the metrics? Is there any configuration I need to do?

What do you see on the project dashboard ? What is the value of the “Duplications on New Lines” measure ?

If it’s 0%, it means that you haven’t added any duplications on the code you’ve added since the leak period.

@julienlancelot yes, it is still 0%
I assume it won’t be displayed if it is 0% or it is a new period but it never has any value yet? I check some of my project, even quality gate is passed, it still displayed duplicated value.

Btw I have some other question about quality gate and it doesn’t belong this topic. If you know this issue, please help me. Here is the link

Thanks a lot @julienlancelot