Does SonarQube supports code coverage in salesforce?


Does SonarQube supports code coverage in salesforce? .Any link for the same.Code coverage is showing 0% always.

I am using below version.

  • Enterprise Edition
  • Version 7.9.3

Hi @naresh2389
and welcome to the SonarSource community!
do you mean that you have some Apex language files analyzed and no coverage shown for them on SonarQube?
In that case SonarQube Test Coverage & Execution documentation page should help you, this page is also linked from the Apex page.
If your project does not meet the requirements (Salesforce CLI used for a Salesforce DX project), you may fallback to the Generic Test Data.

Let me know.
Side note: as you are on a 7.9.3 version, which is not supported anymore, you may want to move to the new LTS (8.9) soon. Is it planned already?

Hi @Sylvain_Combe

Thank you for your response.

I am using ant task for the sfdc validation(sfdc metadata) and passing the same code path to sonarqube for code quality.I am getting vulnerabilities report but I am not able to understand on how to get report file and path for code coverage.can you please help here.

I am not using sfdx cli and it is sfdc(metadata).

Regarding sonar migration i need to check with platform team.

Hi @naresh2389
I’ll let you confirm whether your project meets with the documented prerequisites.
The scanner does not run any test, it needs to find your own test tool (apex:test:run command preferably) outputs. You then need to configure the path of the test execution report as an analysis parameter, with sonar.apex.coverage.reportPath for the supported format.

If you test tool does not provide the expected output, then you’ll need to handle the “transformation” to the SonarSource Generic Test Data format, and use the dedicated analysis parameter (sonar.coverageReportPaths) to allow the scanner to find it.

Same problem here.
I’ve set sonar.apex.coverage.reportPath to path/test-result-codecoverage.json file, and getting zeros for coverage in force-app/main/default/classes/

I don’t really think it’s working properly.