Problem with importing Salesforce code coverage to SonarQube server

  • SonarQube Community Edition 8.9.7, CodeScan plugin 22.1.1, Azure DevOps agent with sonar-scanner installed

Hello I’m trying to get code coverage results from my Salesforce org into SonarQube project. I’m using -Dsonar.apex.coverage.reportPath parameter to point out json file created by sfdx force:apex:test:run Salesforce command. Unfortunately I can’t see any results in my SonarQube project. Here is screenshot of my project, I can’t see any section related to codecoverage and codecoverage graph below is completly blank.

Here is the azure pipeline yaml task.

  • task: Bash@3
    targetType: ‘inline’
    script: |
    sfdx force:apex:test:run -c -d . -r json --wait 4
    sonar-scanner -Dsonar.projectName=$(projectName)$(sqServerAddress) -Dsonar.login=$(sqServerToken) -Dsonar.projectBaseDir=$(salesforceBaseDir) -Dsonar.apex.coverage.reportPath=./test-result-codecoverage.json
    displayName: ‘Run static analysis’


Welcome to the community!

Can you post your analysis logs?


2022-03-23T09:29:52.6523083Z INFO: Scanner configuration file: /root/.sonar/native-sonar-scanner/sonar-scanner-
2022-03-23T09:29:52.6555394Z INFO: Project root configuration file: NONE
2022-03-23T09:29:52.6959957Z INFO: SonarScanner
2022-03-23T09:29:52.6963055Z INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
2022-03-23T09:29:52.6963894Z INFO: Linux 5.13.0-1017-azure amd64
2022-03-23T09:29:53.0020941Z INFO: User cache: /root/.sonar/cache
2022-03-23T09:29:53.0834782Z INFO: Scanner configuration file: /root/.sonar/native-sonar-scanner/sonar-scanner-
2022-03-23T09:29:53.0836875Z INFO: Project root configuration file: NONE
2022-03-23T09:29:53.0959921Z INFO: Analyzing on SonarQube server 9.3.0
2022-03-23T09:29:53.0965933Z INFO: Default locale: "en_US", source code encoding: "US-ASCII" (analysis is platform dependent)
2022-03-23T09:29:53.4418253Z INFO: Load global settings
2022-03-23T09:29:53.5155969Z INFO: Load global settings (done) | time=74ms
2022-03-23T09:29:53.5180541Z INFO: Server id: ...
2022-03-23T09:29:53.5274122Z INFO: User cache: /root/.sonar/cache
2022-03-23T09:29:53.5296864Z INFO: Load/download plugins
2022-03-23T09:29:53.5297586Z INFO: Load plugins index
2022-03-23T09:29:53.5743229Z INFO: Load plugins index (done) | time=44ms
2022-03-23T09:29:53.6698058Z INFO: Load/download plugins (done) | time=140ms
2022-03-23T09:29:54.2280498Z INFO: Process project properties
2022-03-23T09:29:54.2358690Z INFO: Process project properties (done) | time=8ms
2022-03-23T09:29:54.2359541Z INFO: Execute project builders
2022-03-23T09:29:54.2375819Z INFO: Execute project builders (done) | time=2ms
2022-03-23T09:29:54.2426152Z INFO: Project key: salesforce-app
2022-03-23T09:29:54.2427073Z INFO: Base dir: /azp/_work/1/s/force-app
2022-03-23T09:29:54.2432125Z INFO: Working dir: /azp/_work/1/s/force-app/.scannerwork
2022-03-23T09:29:54.2545305Z INFO: Load project settings for component key: 'salesforce-app'
2022-03-23T09:29:54.2688711Z INFO: Load project settings for component key: 'salesforce-app' (done) | time=14ms
2022-03-23T09:29:54.3378677Z INFO: Load project branches
2022-03-23T09:29:54.3806994Z INFO: Load project branches (done) | time=43ms
2022-03-23T09:29:54.3830986Z INFO: Load project pull requests
2022-03-23T09:29:54.4137681Z INFO: Load project pull requests (done) | time=24ms
2022-03-23T09:29:54.4153007Z INFO: Load branch configuration
2022-03-23T09:29:54.4153692Z INFO: Load branch configuration (done) | time=2ms
2022-03-23T09:29:54.4717696Z INFO: Auto-configuring with CI 'Azure DevOps'
2022-03-23T09:29:54.4730879Z INFO: Load quality profiles
2022-03-23T09:29:54.5415066Z INFO: Load quality profiles (done) | time=69ms
2022-03-23T09:29:54.5474947Z INFO: Auto-configuring with CI 'Azure DevOps'
2022-03-23T09:29:54.5480200Z INFO: Load active rules
2022-03-23T09:29:56.8720219Z INFO: Load active rules (done) | time=2324ms
2022-03-23T09:29:56.8994311Z INFO: Branch name: main
2022-03-23T09:29:56.9350743Z INFO: Indexing files...
2022-03-23T09:29:56.9392280Z INFO: Project configuration:
2022-03-23T09:29:56.9393837Z INFO:   Excluded sources: node_modules/**, bower_components/**, jspm_packages/**, typings/**, lib-cov/**
2022-03-23T09:29:57.0987254Z INFO: 4 files indexed
2022-03-23T09:29:57.0987954Z INFO: 0 files ignored because of inclusion/exclusion patterns
2022-03-23T09:29:57.0988419Z INFO: 0 files ignored because of scm ignore settings
2022-03-23T09:29:57.0999613Z INFO: Quality profile for sf: CodeScan way
2022-03-23T09:29:57.1000568Z INFO: Quality profile for xml: Sonar way
2022-03-23T09:29:57.1004061Z INFO: ------------- Run sensors on module test
2022-03-23T09:29:57.1949434Z INFO: Load metrics repository
2022-03-23T09:29:57.2141546Z INFO: Load metrics repository (done) | time=19ms
2022-03-23T09:29:58.1975885Z INFO: Sensor CodeScan indexer [codescan]
2022-03-23T09:29:58.2047941Z INFO: Load project repositories
2022-03-23T09:29:58.2190758Z INFO: Load project repositories (done) | time=14ms
2022-03-23T09:29:58.3592679Z INFO: Running version 22.1.1-ba231
2022-03-23T09:29:58.3593584Z INFO: Project has 50 lines
2022-03-23T09:29:59.0253486Z INFO: CodeScan is licensed. Project salesforce-app size is 50 lines
2022-03-23T09:29:59.0254052Z INFO: Sensor CodeScan indexer [codescan] (done) | time=828ms
2022-03-23T09:29:59.0257726Z INFO: Sensor CodeScan parser [codescan]
2022-03-23T09:29:59.0729451Z INFO: Preparing to run CodeScan analysis
2022-03-23T09:29:59.1465594Z INFO: Preparing to run CodeScan analysis (done) | time=74ms
2022-03-23T09:29:59.1470311Z INFO: Sensor CodeScan parser [codescan] (done) | time=121ms
2022-03-23T09:29:59.1474317Z INFO: Sensor JaCoCo XML Report Importer [jacoco]
2022-03-23T09:29:59.1497816Z INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
2022-03-23T09:29:59.1506699Z INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
2022-03-23T09:29:59.1510721Z INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=3ms
2022-03-23T09:29:59.1514394Z INFO: Sensor CSS Rules [javascript]
2022-03-23T09:29:59.1521359Z INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
2022-03-23T09:29:59.1549789Z INFO: Sensor CSS Rules [javascript] (done) | time=1ms
2022-03-23T09:29:59.1555339Z INFO: Sensor C# Project Type Information [csharp]
2022-03-23T09:29:59.1555745Z INFO: Sensor C# Project Type Information [csharp] (done) | time=1ms
2022-03-23T09:29:59.1556200Z INFO: Sensor C# Analysis Log [csharp]
2022-03-23T09:29:59.1660961Z INFO: Sensor C# Analysis Log [csharp] (done) | time=12ms
2022-03-23T09:29:59.1661640Z INFO: Sensor C# Properties [csharp]
2022-03-23T09:29:59.1663988Z INFO: Sensor C# Properties [csharp] (done) | time=1ms
2022-03-23T09:29:59.1666850Z INFO: Sensor HTML [web]
2022-03-23T09:29:59.1710056Z INFO: Sensor HTML [web] (done) | time=3ms
2022-03-23T09:29:59.1710852Z INFO: Sensor XML Sensor [xml]
2022-03-23T09:29:59.1826280Z INFO: 2 source files to be analyzed
2022-03-23T09:29:59.3692108Z INFO: 2/2 source files have been analyzed
2022-03-23T09:29:59.3696854Z INFO: Sensor XML Sensor [xml] (done) | time=200ms
2022-03-23T09:29:59.3700283Z INFO: Sensor Unit Test Runner [codescan]
2022-03-23T09:29:59.3704135Z INFO: Sensor Unit Test Runner [codescan] (done) | time=1ms
2022-03-23T09:29:59.3705378Z INFO: Sensor CodeScan Checks [codescan]
2022-03-23T09:29:59.3747958Z INFO: Execute CodeScan Apex Analysis 22.1.1
2022-03-23T09:30:00.1784148Z INFO: Execute CodeScan Apex Analysis 22.1.1 (done) | time=803ms
2022-03-23T09:30:00.1785271Z INFO: Execute CodeScan VF Analysis 22.1.1
2022-03-23T09:30:00.1785958Z INFO: Execute CodeScan VF Analysis 22.1.1 (done) | time=0ms
2022-03-23T09:30:00.1789209Z INFO: Execute CodeScan Meta Analysis 22.1.1
2022-03-23T09:30:00.1798492Z INFO: Execute CodeScan Meta Analysis 22.1.1 (done) | time=1ms
2022-03-23T09:30:00.1799588Z INFO: Execute Apex Metrics
2022-03-23T09:30:00.1930458Z INFO: Execute Apex Metrics (done) | time=13ms
2022-03-23T09:30:00.1931451Z INFO: Execute VF Metrics
2022-03-23T09:30:00.1932987Z INFO: Execute VF Metrics (done) | time=1ms
2022-03-23T09:30:00.1934375Z INFO: Sensor CodeScan Checks [codescan] (done) | time=823ms
2022-03-23T09:30:00.1936704Z INFO: Sensor cs-vf Checks [codescanlang]
2022-03-23T09:30:00.1937382Z INFO: Running CodeScanLang
2022-03-23T09:30:00.1957214Z INFO: Sensor cs-vf Checks [codescanlang] (done) | time=2ms
2022-03-23T09:30:00.1958290Z INFO: Sensor cs-js Checks [codescanlang]
2022-03-23T09:30:00.1959180Z INFO: Running CodeScanLang
2022-03-23T09:30:00.1961292Z INFO: Sensor cs-js Checks [codescanlang] (done) | time=0ms
2022-03-23T09:30:00.1962250Z INFO: Sensor Text Sensor [text]
2022-03-23T09:30:00.2032859Z INFO: 4 source files to be analyzed
2022-03-23T09:30:00.2036272Z INFO: 4/4 source files have been analyzed
2022-03-23T09:30:00.2036960Z INFO: Sensor Text Sensor [text] (done) | time=7ms
2022-03-23T09:30:00.2040404Z INFO: Sensor VB.NET Project Type Information [vbnet]
2022-03-23T09:30:00.2053424Z INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms
2022-03-23T09:30:00.2054196Z INFO: Sensor VB.NET Analysis Log [vbnet]
2022-03-23T09:30:00.2188112Z INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=12ms
2022-03-23T09:30:00.2189371Z INFO: Sensor VB.NET Properties [vbnet]
2022-03-23T09:30:00.2189707Z INFO: Sensor VB.NET Properties [vbnet] (done) | time=1ms
2022-03-23T09:30:00.2190205Z INFO: Sensor com.github.mc1arke.sonarqube.plugin.scanner.ScannerPullRequestPropertySensor
2022-03-23T09:30:00.2190740Z INFO: Sensor com.github.mc1arke.sonarqube.plugin.scanner.ScannerPullRequestPropertySensor (done) | time=0ms
2022-03-23T09:30:00.2191207Z INFO: Sensor Apex CPD [codescan]
2022-03-23T09:30:00.2298386Z INFO: Sensor Apex CPD [codescan] (done) | time=11ms
2022-03-23T09:30:00.2352650Z INFO: Sensor VisualForce/Lightning CPD [codescan]
2022-03-23T09:30:00.2356028Z INFO: Sensor VisualForce/Lightning CPD [codescan] (done) | time=1ms
2022-03-23T09:30:00.2389176Z INFO: ------------- Run sensors on project
2022-03-23T09:30:00.2537837Z INFO: Sensor Zero Coverage Sensor
2022-03-23T09:30:00.2545182Z INFO: Sensor Zero Coverage Sensor (done) | time=1ms
2022-03-23T09:30:00.2610658Z INFO: SCM Publisher SCM provider for this project is: git
2022-03-23T09:30:00.2761754Z INFO: SCM Publisher 1 source file to be analyzed
2022-03-23T09:30:00.4119283Z INFO: SCM Publisher 1/1 source file have been analyzed (done) | time=137ms
2022-03-23T09:30:00.4144071Z INFO: CPD Executor Calculating CPD for 2 files
2022-03-23T09:30:00.4243843Z INFO: CPD Executor CPD calculation finished (done) | time=9ms
2022-03-23T09:30:00.5329708Z INFO: Load New Code definition
2022-03-23T09:30:00.5508944Z INFO: Load New Code definition (done) | time=17ms
2022-03-23T09:30:00.5566171Z INFO: Analysis report generated in 128ms, dir size=135.7 kB
2022-03-23T09:30:00.5890673Z INFO: Analysis report compressed in 32ms, zip size=23.4 kB
2022-03-23T09:30:00.6093294Z INFO: Analysis report uploaded in 19ms
2022-03-23T09:30:00.6113800Z INFO: ANALYSIS SUCCESSFUL, you can browse ...
2022-03-23T09:30:00.6118595Z INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
2022-03-23T09:30:00.6123395Z INFO: More about the report processing at ...
2022-03-23T09:30:00.6193030Z INFO: Analysis total time: 6.839 s
2022-03-23T09:30:00.6222593Z INFO: ------------------------------------------------------------------------
2022-03-23T09:30:00.6226628Z INFO: EXECUTION SUCCESS
2022-03-23T09:30:00.6230313Z INFO: ------------------------------------------------------------------------
2022-03-23T09:30:00.6235087Z INFO: Total time: 7.985s
2022-03-23T09:30:00.7110135Z INFO: Final Memory: 17M/57M
2022-03-23T09:30:00.7111721Z INFO: --------------------------


What edition are you in? If you’re running Developer Edition($) then Apex isn’t included and you’ll need to talk to your 3rd-party vendor about this. If you’re in Enterprise Edition($$), then Apex analysis is included, and you presumably don’t need this 3rd-party vendor.


I’m using SonarQube Community Edition 8.9.7, so there is no way to get code coverage using sonar.apex.coverage.reportPath property?


It looks like you’ve got a 3rd-party plugin loaded for basic analysis. You should talk to them about coverage too. That or take a look at converting your reports to the Generic Coverage format.