Code Analysis fails submission to SonarCloud

Hi Guys,
I need someone to help point me in the right direction when getting my code analysis to report correctly to Sonarcloud. When I go to my report it just says “Failed”. It looks to me like the report is incomplete.

  • ALM used, Bitbucket Cloud, Azure DevOps
  • CI system used Bitbucket Cloud, Azure DevOps
  • Languages of the repository - Nodejs 12.16.1, Typescript, Angular,JS
  • SonarCloud project is public

sonar-project.properties

sonar.organization=responsive
sonar-projectBaseDir=/application/
sonar.projectKey=ah2s2bp4zd5wsteqwqa6h4ygu
sonar.host.url=https://sonarcloud.io
sonar.dynamicAnalysis=reuseReports
typescript.lcov.reportPaths=/lcov.info
sonar.exclusions=application/tests
sonar.log.level=DEBUG
sonar.sources=.
sonar.language=js

Hi @Sacha_Wharton and welcome to the community !

Given your properties, it seems that you use a wrong one (which is supposed to be prefixed by sonar. and, this one is deprecated.

Can you please test with sonar.javascript.coverage.reportPaths ?

Thanks.
Mickaël

Hi Mickaël,

Thank you so much for the response. I am going to give it a go and let you know.

Hi Mickaël,

Unfortunately it still shows as “Failed” in the Sonarcloud portal. I must still be missing something.

sonar-project.properties

sonar.organization=responsive
sonar-projectBaseDir=/application/
sonar.projectKey=ah2s2bp4zd5wsteqwqa6h4ygu
sonar.host.url=https://sonarcloud.io
sonar.dynamicAnalysis=reuseReports
sonar.javascript.coverage.reportPaths=.
sonar.exclusions=application/tests
sonar.log.level=DEBUG
sonar.sources=.
sonar.language=js

Tail end of the Azure DevOps Log

INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=44ms
INFO: SCM Publisher SCM provider for this project is: git
INFO: SCM Publisher 10 source files to be analyzed
INFO: SCM Publisher 10/10 source files have been analyzed (done) | time=336ms
INFO: CPD Executor 124 files had no CPD blocks
INFO: CPD Executor Calculating CPD for 302 files
INFO: CPD Executor CPD calculation finished (done) | time=160ms
INFO: SCM writing changed lines
WARN: File '/home/vsts/work/1/s/Application/libs/beneficiaries/src/lib/components/add-beneficiary/add-beneficiary.component.html' was detected as changed but without having changed lines
INFO: SCM writing changed lines (done) | time=113ms
INFO: Analysis report generated in 255ms, dir size=493 KB
INFO: Analysis report compressed in 332ms, zip size=404 KB
INFO: Analysis report uploaded in 636ms
INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=ah2s2bp4zd5wsteqwqa6h4ygu&branch=devops%2Fsacha-pipeline-testing&resolved=false
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=AXE68RHKKmyaVLOYGMHr
INFO: Analysis total time: 57.573 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:21.165s
INFO: Final Memory: 34M/237M
INFO: ------------------------------------------------------------------------

Tail end of the Azure DevOps Log with debugging and verbose enabled

15:40:24.434 INFO: Analysis report generated in 278ms, dir size=493 KB
15:40:24.730 INFO: Analysis report compressed in 296ms, zip size=404 KB
15:40:24.731 INFO: Analysis report generated in /home/vsts/work/1/s/.scannerwork/scanner-report
15:40:24.731 DEBUG: Upload report
15:40:25.311 DEBUG: POST 200 https://sonarcloud.io/api/ce/submit?organization=ewru9576092345hfoijopiuer&projectKey=ah2s2bp4zd5wsteqwqa6h4ygu&characteristic=branch%3Ddevops%2Fsacha-pipeline-testing&characteristic=branchType%3DSHORT | time=580ms
15:40:25.313 INFO: Analysis report uploaded in 582ms
15:40:25.316 DEBUG: Report metadata written to /home/vsts/work/_temp/sonar/20200402.11/82ca4ebe-2167-4ac7-8ee9-e70e64f87ec0/report-task.txt
15:40:25.316 INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=ah2s2bp4zd5wsteqwqa6h4ygu&branch=devops%2Fsacha-pipeline-testing&resolved=false
15:40:25.316 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
15:40:25.316 INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=AXE7jPMQY23ySF6ceGMP
15:40:25.319 DEBUG: Post-jobs : 
15:40:25.322 DEBUG: eslint-bridge server will shutdown
15:40:25.539 DEBUG: stylelint-bridge server will shutdown
15:40:25.541 INFO: Analysis total time: 1:01.077 s
15:40:25.543 INFO: ------------------------------------------------------------------------
15:40:25.543 INFO: EXECUTION SUCCESS
15:40:25.543 INFO: ------------------------------------------------------------------------
15:40:25.543 INFO: Total time: 1:25.652s
15:40:25.718 INFO: Final Memory: 34M/232M
15:40:25.718 INFO: ------------------------------------------------------------------------
Finishing: Run Code Analysis

Sonarcloud now gives me a green “passed” with the following config:
It says no bugs, vulnerabilities or code smells. This seems to good to be true?

sonar-project.properties

sonar.organization=responsive
sonar-projectBaseDir=/application/
sonar.projectKey=ah2s2bp4zd5wsteqwqa6h4ygu
sonar.dynamicAnalysis=reuseReports
sonar.javascript.coverage.reportPaths=coverage
sonar.log.level=DEBUG
sonar.verbose=true
sonar.sources=.

Hi,

You need to give the full path to the lcov.info file in this property (at least the relative one)

And, BTW, this one : sonar.dynamicAnalysis=reuseReports doesn’t exist anymore since a long time :slight_smile:

Mickaël

Hi Mickaël,

Thanks very much for the feedback. I am totally new at this. I will go and give that a try.

Hi Mickaël,

Ok so I removed sonar.dynamicAnalysis=reuseReports.
I am still foggy on what path to put here —> sonar.javascript.coverage.reportPaths
Unfortunately its still not reporting the info to Sonarcloud. Do I need to add Maven or Gradle?

sonar-project.properties
sonar.organization=responsive
sonar-projectBaseDir=/application/
sonar.projectKey=ah2s2bp4zd5wsteqwqa6h4ygu
sonar.javascript.coverage.reportPaths=coverage/lcov.info
sonar.sources=.

Hi,

I think i’ll need the full log of the Run Code Analysis to help understand. Could you please provide it ?

Thanks.

Should I enable debug and verbose?

Yes please

Here you go. rawlog.txt (3.1 MB)

I was really hoping I had found the solution by updating the report path as in the below config.

sonar-project.properties

# --- required properties ---
sonar.organization=responsive
sonar-projectBaseDir=/application/
sonar.projectKey=ah2s2bp4zd5wsteqwqa6h4ygu

# --- optional properties ---
sonar.javascript.coverage.reportPaths=application/node_modules/react-dev-utils/node_modules/mute-stream/coverage/lcov-report/lcov.info
#sonar.log.level=DEBUG
#sonar.verbose=true

# defaults to project key
#sonar.projectName=My project
# defaults to 'not provided'
#sonar.projectVersion=1.0
 
# Path is relative to the sonar-project.properties file. Defaults to .
sonar.sources=.

I realise that path won’t work as node_modules is added to .gitignore.

Hi Mickaël,

Any joy with my config?

Thank you.

node_modules is probably added to yout gitignore, but it’s generated again i guess as you do an npm install in your build pipeline, but the path to a coverage file seems to be too deep here, can you specify one that is pretty close to the root path ? Did you try to open that generated file to see if there’s data inside ?

Hi Mickaël,

Thank you for your assistance. I will take a look at that in the future. You can close this call out for now.