Quality gate condition for 0 files scanned not working


(Jason Stanley) #1

Hello

SonarQube version 6.7.2 LTS

I want to define a condition in our quality gate that will fail if a scan is run against 0 files.

I see under conditions you have a “Files” metric and when I set the “Operator” to equals and specify 0 for “Warning” and “Error” .

When I run a scan against 0 files, this condition is not caught.

I have tried specifying 0 for just Warning and Error, and this still does not work.

Can someone please shed some light on this problem?

Thanks
Jason


(Julien Lancelot) #2

Hi,

If there’s no file in a report, then most probably there will be no measure at all, so indeed you won’t be able to set a quality gate on any metric.

May I ask you why you need to specify such condition on project without file ?
Because the quality gate is used to ensure the quality of your project is on the right path, but if there’s no file, then there’s no code, then there’s no quality, then there’s nothing to check.

Regards,
Julien Lancelot


(Jason Stanley) #3

Hi Julien

I have scans where no files were scanned and the quality gate passed. I need a way to fail if a scan did not scan any files. Is this possible?

Jason


(Julien Lancelot) #4

Hi,

Maybe you can try to provide a Sensor in a custom plugin.
See some info about it here : https://docs.sonarqube.org/display/DEV/API+Basics

Regards,
Julien Lancelot