sonar-cxx and msbuild runner set-up

292 views
Skip to first unread message

Shaun Wilde

unread,
Jan 26, 2016, 4:35:06 PM1/26/16
to SonarQube
I am trying to integrate the community sonar-cxx plugin but I am not convinced I have integrated it correctly as I am finding no issues (except for a single duplicated block)

It is correctly reporting the number of lines as well and the c# integration continues to report the same issues as before so that's not broken.

If someone is able to check the command below and steer me in the right direction that would be great (I also tried the regex with single \ rather then double \\)

These are the commands I am issuing (derived from https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Compilers)

\Projects\sonarqube-runner\MSBuild.SonarQube.Runner.exe begin /n:"opencover" /k:"opencover" /v:"0.0.0.10" /d:sonar.cxx.compiler.reportPath=example.log /d:sonar.cxx.compiler.parser="Visual C++" /d:sonar.cxx.compiler.charset=UTF-8 /d:sonar.cxx.compiler.regex="^.*>(?<filename>.*)\\((?<line>[0-9]+)\\):\\x20warning\\x20(<id>C\\d\\d\\d\\d):(?<message>.*)$"

msbuild main\OpenCover.sln /t:rebuild /p:Configuration=Release;WarningLevel=3 /fileLogger /fileLoggerParameters:WarningsOnly;LogFile=example.log;Verbosity=detailed;Encoding=UTF-8 /v:Detailed

\Projects\sonarqube-runner\MSBuild.SonarQube.Runner.exe end

and this is the output log from the build (and I see some I should address)

CodeCoverage_Support.cpp(21): warning C4278: 'ReportEvent': identifier in type library 'mscorlib.tlb' is already a macro; use the 'rename' qualifier [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
cl : Command line warning D9032: '-doc' : XML documentation comments are not supported by the C compiler [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
cl : Command line warning D9032: '-doc' : XML documentation comments are not supported by the C compiler [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
x64\Release\OpenCoverProfiler_i.xdc : warning XDC0006: file(s) not found [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
x64\Release\xdlldata.xdc : warning XDC0006: file(s) not found [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
c:\projects\opencover.git\working\main\opencover.profiler\codecoverage.cpp(28): warning C6031: Return value ignored: 'StringFromGUID2'. [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
c:\projects\opencover.git\working\main\opencover.profiler\codecoverage_support.cpp(45): warning C6387: 'hClrHookDllHGlb' could be '0':  this does not adhere to the specification for the function 'LockResource'.  [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
c:\projects\opencover.git\working\main\opencover.profiler\codecoverage_support.cpp(43): warning C6387: 'hClrHookDllRes' could be '0':  this does not adhere to the specification for the function 'SizeofResource'. See line 40 for an earlier location where this can occur [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
c:\projects\opencover.git\working\main\opencover.profiler\codecoverage_support.cpp(40): warning C6387: 'hClrHookDllRes' could be '0':  this does not adhere to the specification for the function 'LoadResource'.  [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
c:\projects\opencover.git\working\main\opencover.profiler\codecoverage_support.cpp(57): warning C6102: Using 'lpArrayData' from failed function call at line '56'. [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
c:\projects\opencover.git\working\main\opencover.profiler\codecoverage_support.cpp(120): warning C6216: Compiler-inserted cast between semantically different integral types:  a Boolean type to HRESULT. [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
c:\projects\opencover.git\working\main\opencover.profiler\codecoverage_support.cpp(98): warning C6102: Using 'ext' from failed function call at line '97'. [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
c:\projects\opencover.git\working\main\opencover.profiler\profilercommunication.cpp(562): warning C6255: _alloca indicates failure by raising a stack overflow exception.  Consider using _malloca instead. [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
c:\projects\opencover.git\working\main\opencover.profiler\profilercommunication.cpp(567): warning C6255: _alloca indicates failure by raising a stack overflow exception.  Consider using _malloca instead. [C:\Projects\opencover.git\working\main\OpenCover.Profiler\OpenCover.Profiler.vcxproj]
Program.cs(75,61): warning CS0168: The variable 'eex' is declared but never used [C:\Projects\opencover.git\working\main\OpenCover.Console\OpenCover.Console.csproj]
Program.cs(379,30): warning CS0168: The variable 'ex' is declared but never used [C:\Projects\opencover.git\working\main\OpenCover.Console\OpenCover.Console.csproj]

Thanks

Jorge Costa

unread,
Jan 27, 2016, 12:16:34 AM1/27/16
to Shaun Wilde, SonarQube

Hi
You could try this wrapper: https://github.com/jmecsoftware/sonar-cxx-msbuild-tasks

Those properties that you defined in command line can be put in a sonar-propreties file that it will be picked up and translated into the msbuild runner. More likely its not running because of path issues, the msbuild runner looks for stuff in the workdir that is inside .sonarqube folder therefore you need to use absolute paths. If your are using 0.9.4 this may not work, the support for absolute is available after this, but you can upgrade if does not work with 0.9.4 https://ci.appveyor.com/project/SonarOpenCommunity/sonar-cxx/branch/master/artifacts

Br,
Jorge Costa


--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/76e84e18-3ad8-4a5e-a94a-7c7f0e527894%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shaun Wilde

unread,
Jan 27, 2016, 5:13:19 AM1/27/16
to SonarQube, shaun.wi...@gmail.com
I'll give it  a go but after closer analysis I noticed some ERROR messages from the analyzer (hidden amongst a raft of WARN messages) e.g.

21:06:24.060 ERROR - Unable to parse file: C:\Projects\opencover.git\working\mai
n\OpenCover.Profiler\CodeCoverage.h


 31:
 32:
-->  typedef void(__fastcall *ipv)(ULONG);
 34:
 35:
 36:

and I think this may account for the failure, I'll raise this on the github project
Reply all
Reply to author
Forward
0 new messages