C++ community can't extract msbuild warnings for SonarQube

Hi,

I want export warning from c++ msbuild.log file to sonarqube, using c++ community plugin,
after exporting, sonarqube has provided no result.

I’m using this process

E:\BetaTesting_SCA_Suite\sonar-scanner-msbuild-4.7.1.2311-net46>SonarScanner.MSBuild.exe begin /k:"vsbuildlog"

E:\BetaTesting_SCA_Suite\sonar-scanner-msbuild-4.7.1.2311-net46>“C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe” “E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\cppcheck.sln” /t:rebuild /p:Configuration=Release;WarningLevel=3 /fileLogger /fileLoggerParameters:WarningsOnly;LogFile=E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\buildlog.log;Verbosity=detailed;Encoding=UTF-8

E:\BetaTesting_SCA_Suite\sonar-scanner-msbuild-4.7.1.2311-net46>SonarScanner.MSBuild.exe end

After above process i got this output

INFO: Sensor C++ (Community) SquidSensor [cxx] (done) | time=2188ms
INFO: Sensor C++ (Community) CxxCompilerVcSensor [cxx]
INFO: Searching reports by relative path with basedir ‘E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87’ and search prop 'sonar.cxx.vc.reportPath’
INFO: Parser will parse ‘1’ report file(s)
INFO: Processing report 'E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\buildlog.log’
INFO: Parsing ‘Visual C++’ initialized with report ‘E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\buildlog.log’, Charset= 'UTF-8’
INFO: Using pattern : '(.>)?(?.)((?\d+))\x20:\x20warning\x20(?C\d+):(?.*)'
INFO: CXX-COMPILER-VC processed = 0
INFO: Sensor C++ (Community) CxxCompilerVcSensor [cxx] (done) | time=16640ms

as you can see, no warnings are processed but, buildlog.log contains many warnings.

buildlog.log Warnings:

e:\betatesting_testingframework\customcppcheckrules\cppcheck-1.87\customrules\checkcustomconditions.h(79): warning C4100: ‘settings’: unreferenced formal parameter (compiling source file …\customrules\checkcustomconditions.cpp) [E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\lib\cppcheck.vcxproj]
** e:\betatesting_testingframework\customcppcheckrules\cppcheck-1.87\customrules\checkcustomrulesclass.h(48): warning C4100: ‘tokenizer’: unreferenced formal parameter (compiling source file …\customrules\checkcustomrulesclass.cpp) [E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\lib\cppcheck.vcxproj]**
** e:\betatesting_testingframework\customcppcheckrules\cppcheck-1.87\customrules\checkcustomconditions.h(79): warning C4100: ‘tokenizer’: unreferenced formal parameter (compiling source file …\customrules\checkcustomconditions.cpp) [E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\lib\cppcheck.vcxproj]**
** …\customrules\checkcustomfunctions.cpp(347): warning C4189: ‘scopeIndex’: local variable is initialized but not referenced [E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\lib\cppcheck.vcxproj]**
** …\customrules\checkcustomfunctions.cpp(353): warning C4189: ‘scope’: local variable is initialized but not referenced [E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\lib\cppcheck.vcxproj]**
** …\customrules\checkcustomfunctions.cpp(361): warning C4189: ‘bIsOperator’: local variable is initialized but not referenced [E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\lib\cppcheck.vcxproj]**
** …\customrules\checkcustomfunctions.cpp(416): warning C4189: ‘bRetValue’: local variable is initialized but not referenced [E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\lib\cppcheck.vcxproj]**
** …\customrules\checkcustomconditions.cpp(169): warning C4189: ‘scopeList’: local variable is initialized but not referenced [E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\lib\cppcheck.vcxproj]**

am passing the below properties in sonarqube.analysis.xml
sonar.cxx.vc.reportPath=E:\BetaTesting_Testingframework\CustomCppcheckRules\cppcheck-1.87\buildlog.log
sonar.cxx.vc.charset=UTF-8

I’m using SonarQube Version 7.9.1
sonar-scanner-msbuild-4.7.1.2311-net46
C++ (Community) 1.3.1.1807 (cxx)

Reference link: https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Compilers

when i use the sonar.cxx.vc.regex=(.>)?(?.)\((?\d+)\)\x20:\x20warning\x20(?C\d+):(?.*) property in sonarqube.analysis.xml file it hits the below error message

Loading analysis properties from E:\BetaTesting_SCA_Suite\sonar-scanner-msbuild-4.7.1.2311-net46\SonarQube.Analysis.xml
Unable to read the SonarQube analysis settings file ‘E:\BetaTesting_SCA_Suite\sonar-scanner-msbuild-4.7.1.2311-net46\SonarQube.Analysis.xml’. Please fix the content of this file.

But if you notice in the output after build, without providing regex property its using the below regex pattern.
INFO: Using pattern : '(.>)?(?.)((?\d+))\x20:\x20warning\x20(?C\d+):(?.*)'

Can you help me to resolve this Issue?

Regards
Sheetal

Sheetal,

The community C++ plugin isn’t supported on this forum. I would recommend raising an issue with the maintainer!

Colin

1 Like