SonarOpenCommunity / sonar-cxx

SonarQube C++ Community plugin (cxx plugin): This plugin adds C++ support to SonarQube with the focus on integration of existing C++ tools.
GNU Lesser General Public License v3.0
988 stars 364 forks source link

Not getting sonar report while using sonar-cxx for SonarQube 9.9.5 LTS #2683

Closed nirajsinha73 closed 3 months ago

nirajsinha73 commented 3 months ago

Hi I am using SonarQube 9.9.5 LTS and cxx plugin 2.1.1 after getting successfully execution of sonarqube no report published on sonarqube dashboard.

Below configuration using for sonarqube.

 C:\\apps\\sonar-scanner\\bin\\sonar-scanner.bat -e \
                        -Dsonar.host.url=http:\\*****:9000 \
                        -Dsonar.sources=. \
                        -Dsonar.projectVersion=%REPORT_VERSION% \
                        -Dsonar.projectName=%PROJECT_NAME% \
                        -Dsonar.projectKey=%PROJECT_KEY% \
                        -Dsonar.sourceEncoding=UTF-8 \
                        -Dsonar.projectBaseDir=%RELEASE_WORKSPACE%\\output\\precompiled\\ \
                        -Dsonar.cxx.cppcheck.reportPath=%RELEASE_WORKSPACE%\\output\\cppcheck.xml \
                        -Dsonar.cxx.coverage.reportPath=%RELEASE_WORKSPACE%\\output\\UTCoverageReport.xml \
                        -Dsonar.cxx.xunit.reportPath=%RELEASE_WORKSPACE%\\output\\iFDmgr_UT-Results.xml \
                        -Dsonar.cxx.valgrind.reportPath=%RELEASE_WORKSPACE%\\output\\UTValgrindReport.xml \
                        -Dsonar.cxx.compiler.regex="^(.*):([0-9]+): warning: (.*)\\[(.*)\\]$" \
                        -Dsonar.cxx.compiler.parser=GCC \
                        -Dsonar.cxx.compiler.charset=UTF-8 \
                        -Dsonar.cxx.compiler.reportPath=%RELEASE_WORKSPACE%\\output\\make.log

Below are the logs of sonarqube.

INFO: Load project settings for component key: 'iFDmgr_05.01.01'
INFO: Load project settings for component key: 'iFDmgr_05.01.01' (done) | time=161ms
INFO: Auto-configuring with CI 'Jenkins'
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=206ms
INFO: Load active rules
INFO: Load active rules (done) | time=5105ms
INFO: Load analysis cache
INFO: Load analysis cache (404) | time=153ms
WARN: Property 'sonar.password' is deprecated. It will not be supported in the future. Please instead use the 'sonar.login' parameter with a token.
INFO: Load project repositories
INFO: Load project repositories (done) | time=163ms
INFO: Indexing files...
INFO: Project configuration:
INFO: 32 files indexed
INFO: ------------- Run sensors on module iFDmgr_05.01.01
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=158ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
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
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=1ms
INFO: Sensor CSS Rules [javascript]
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor CSS Rules [javascript] (done) | time=1ms
INFO: Sensor C# Project Type Information [csharp]
INFO: Sensor C# Project Type Information [csharp] (done) | time=0ms
INFO: Sensor C# Analysis Log [csharp]
INFO: Sensor C# Analysis Log [csharp] (done) | time=8ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=1ms
INFO: Sensor TextAndSecretsSensor [text]
INFO: Sensor TextAndSecretsSensor [text] (done) | time=4ms
INFO: Sensor VB.NET Project Type Information [vbnet]
INFO: Sensor VB.NET Project Type Information [vbnet] (done) | time=1ms
INFO: Sensor VB.NET Analysis Log [vbnet]
INFO: Sensor VB.NET Analysis Log [vbnet] (done) | time=11ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=0ms
INFO: Sensor IaC Docker Sensor [iac]
INFO: 0 source files to be analyzed
INFO: 0/0 source files have been analyzed
INFO: Sensor IaC Docker Sensor [iac] (done) | time=38ms
INFO: ------------- Run sensors on project
INFO: Sensor Analysis Warnings import [csharp]
INFO: Sensor Analysis Warnings import [csharp] (done) | time=1ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=3ms
INFO: SCM Publisher is disabled
INFO: CPD Executor Calculating CPD for 0 files
INFO: CPD Executor CPD calculation finished (done) | time=0ms
INFO: Analysis report generated in 66ms, dir size=155.9 kB
INFO: Analysis report compressed in 15ms, zip size=18.2 kB
INFO: Analysis report uploaded in 175ms
INFO: ANALYSIS SUCCESSFUL, 

Below are the sonar dashboard.

image

guwirth commented 3 months ago

Hi @nirajsinha73,

please read https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Scan-Source-Code https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Scan-Report-Files https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Troubleshooting-Configuration

Most likely it’s missing https://github.com/SonarOpenCommunity/sonar-cxx/wiki/sonar.cxx.file.suffixes

Regards,

nirajsinha73 commented 3 months ago

Hi guwirth,

Thanks for your response. I have followed all the steps but still issue is not resolved. I am using below are sonar properties

C:\\apps\\sonar-scanner\\bin\\sonar-scanner.bat -e \
                        -Dsonar.host.url=http:\\*******:9000 \
                        -Dsonar.sources=%RELEASE_WORKSPACE%\\output\\precompiled\\ \
                        -Dsonar.projectVersion=%REPORT_VERSION% \
                        -Dsonar.projectName=%PROJECT_NAME% \
                        -Dsonar.projectKey=%PROJECT_KEY% \
                        -Dsonar.sourceEncoding=UTF-8 \
                        -Dsonar.projectBaseDir=%RELEASE_WORKSPACE%\\output\\precompiled\\ \
                        -Dsonar.cxx.cppcheck.reportPath=%RELEASE_WORKSPACE%\\output\\cppcheck.xml \
                        -Dsonar.cxx.coverage.reportPath=%RELEASE_WORKSPACE%\\output\\UTCoverageReport.xml \
                        -Dsonar.cxx.xunit.reportPath=%RELEASE_WORKSPACE%\\output\\iFDmgr_UT-Results.xml \
                        -Dsonar.cxx.valgrind.reportPath=%RELEASE_WORKSPACE%\\output\\UTValgrindReport.xml \
                        -Dsonar.cxx.compiler.regex="^(.*):([0-9]+): warning: (.*)\\[(.*)\\]$" \
                        -Dsonar.cxx.compiler.parser=GCC \
                        -Dsonar.cxx.compiler.charset=UTF-8 \
                        -Dsonar.projectDate=%PROJECT_DATE% \
                        -Dsonar.cxx.compiler.reportPath=%RELEASE_WORKSPACE%\\output\\make.log
                        -Dsonar.cxx.file.suffixes=.cxx,.cpp,.cc,.c,.hxx,.hpp,.hh,.h
                        -Dsonar.c.file.suffixes=-

Please suggest if i need to update sonar properties.

guwirth commented 3 months ago

Hi @nirajsinha73,

please turn debug logging on https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Get-Debug-Information

And compare with https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Troubleshooting-Configuration

Important is that you see source files listed below File Indexing.

Regards,

nirajsinha73 commented 3 months ago

Hi guwirth Thanks For your quick response. Finally, issue has been resolved i was used wrong configuration in sonar CXX UI.

nirajsinha73 commented 3 months ago

Hi guwirth

Now i am able to see the sonar dashboard but still getting code coverage 0%. Manually i have verified the coverage.xml and found that coverage report is correct.

image

image

Below are the coverage properties i have tried. but still not getting code coverage

-Dsonar.cxx.coverage.reportPaths=%RELEASE_WORKSPACE%/output/UTCoverageReport.xml or -Dsonar.coverageReportPaths=%RELEASE_WORKSPACE%/output/UTCoverageReport.xml or -Dsonar.cxx.cobertura.reportPaths=%RELEASE_WORKSPACE%\output\UTCoverageReport.xml

guwirth commented 3 months ago

Hi @nirajsinha73,

please open in future a new issue for a new problem.

For importing reports read the link below, especially the Troubleshooting and .LOG file section https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Scan-Report-Files

Cobertura sensor: https://github.com/SonarOpenCommunity/sonar-cxx/wiki/sonar.cxx.cobertura.reportPaths

Most likely it’s a file path issue: the path in the report must match to the indexed source paths. https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Troubleshooting-Reports

Regards,

nirajsinha73 commented 3 months ago

Hi guwirth

Thanks for your response now i am able to generate code coverage. issue is with projectBasedir location.