Sonarqube cfamily analysis without project or solution file

Note that the project is not based on .project or .sln file, its a folder from a microchip project

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
Server ID	10173C1E-AW-OunQtiDNiDb7hDFkk
Version	8.1.0.31237
SonarCFamilyLANGUAGES
Code Analyzer for C, C++, Objective-C
6.5.0 (build 12506)installed
I currentlty have a 2 week trial edition of the developer edition
  • what are you trying to achieve
I try to analyse a folder containing .c and .h files for misra faults.
Note there is no other files just 1 folder containing source files.

  • what have you tried so far to achieve this
I created a folder named trunk.
Inside this folder I created a folder named source and in this folder I placed a lot of .c and .h files.
Then I added another folder named analyse in the folder trunk.

I then run the following command.

sonar-scanner.bat -X -Dsonar.host.url=http://10.10.20.211:9001 -Dsonar.login=dbcc2f2e50fc45d5b8b9129d4de69bc38fe888bd -Dsonar.sourceEncoding=UTF-8 -Dsonar.sources=source  -Dsonar.working.directory=sonarWD -Dsonar.projectKey=mykey- -Dsonar.cfamily.build-wrapper-output=analyse -Dsonar.sourceEncoding=UTF-8"

I got a warning message with:

java.lang.IllegalStateException: java.nio.file.NoSuchFileException: C:\trunk\analyse\build-wrapper-dump.json

	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:340)

I then looked in the documentation and found I need to execute a process named:

build-wrapper-win-x86-64.exe --out-dir  build_wrapper_output_directory MSBuild.exe /t:Rebuild

This is strange for me. Because Msbuild is based on .project or .sln file to build code.
But in this case I only want that sonarqube analyse the .c and .h files and shows me faults in sonarqube. I dont want to build any code I want to analyse a source folder.

What is going on here or isnt sonarqube capable of this?

Edit:
I created a project file manual named: project.vcxproj
I included

<Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <ProjectConfiguration Include="Debug|Win32">
      <Configuration>Debug</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
    <ProjectConfiguration Include="Release|Win32">
      <Configuration>Release</Configuration>
      <Platform>Win32</Platform>
    </ProjectConfiguration>
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.default.props" />
  <PropertyGroup>
    <ConfigurationType>Application</ConfigurationType>
    <PlatformToolset>v142</PlatformToolset>
  </PropertyGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  <ItemGroup>
    <ClCompile Include="source/action_states.c" />
  </ItemGroup>
  <ItemGroup>
    <ClInclude Include="source/action_states.h" />
  </ItemGroup>
  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Targets" />
</Project>

Then I ran the msbuild command in any hope and got this

C:\build-wrapper-win-x86-64.exe --out-dir C:\trunk\analyse C:\trunk\MSBuild.exe /t:Rebuild
[SONARSOURCE BUILD-WRAPPER] failed to execute C:\trunk\MSBuild.exe /t:Rebuild: The system cannot find the file specified.

Hello @ralphvbair,

MSBuild.exe /t:Rebuild is just an example you shouldn’t use it if you don’t build with msbuild. You should replace this part with the command that you usually use to clean build your project.

Thanks @Abbas_Sabra

However, Why must I clean build the project. cause there is no project. there is just a bunch of source files. no compiling is required in this case.

I cannot even build the code its more now for static analysis.

Then we need the command you use to build these files.

We need this command to deduce the language standard/flags/libraries/… you are using.
The way you build your project impacts how your code behaves and consequently, it should impact the results of the static analysis.
That why we cannot analyze files without knowing how you build them.

Ok im going to post it here, we use xc8 and gcc for testing.

Is it enough to share gcc command?

or like to execute this

build-wrapper-win-x86-64.exe --out-dir C:\trunk\analyse gcc anysourcepath?

the problem is that we use libaries from the microchip library these are not included in the svn folder.
I solved this to create a dummy library file with ifdefs in including in the source files.

here a gcc for a test file

'gcc.exe -E -I"test/test" -I"test/test/support" -I"source" -I"C://test/vendor/ceedling/vendor/unity/src" -I"C:/test/vendor/ceedling/vendor/cmock/src" -I"build/test/mocks" -DTEST -D_HOSTED -D_GCC -D_18F6680 -DUNITY_INT_WIDTH=32 -DCMOCK_MEM_INDEX_TYPE=uint64_t -DCMOCK_MEM_PTR_AS_INT=uint64_t -DCMOCK_MEM_SIZE=2056 -DCODE_COVERAGE -DTEST -D_HOSTED -D_18F6680 -DGNU_COMPILER "test/test/test_ascu_init.c" -o "build/test/preprocess/files/test_ascu_init.c"'

However we have never build the source code with gcc itself only with the xc8 compiler using microchip specifics.

Here the xc8 compiler code for one .c file

xc8 -V --pass1 --chip=18F6680 -Q -G --double=24 --float=24 --emi=wordwrite --rom=default,-000-02FF --opt=+asm,+asmfile,-speed,+space,-debug,-local --addrqual=ignore --mode=pro -D_BUILD_FOR_RELEASE -P -N255 --warn=-9 --asmlist -DXPRJ_Build_for_release=Build_for_release --summary=default,-psect,-class,+mem,+hex,-file --codeoffset=0x0300 --checksum=300-FFFD@FFFE --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+download,-config,+clib,-plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto -obuild/action_states.p1 source/action_states.c 

if this command build the source file succefully. Then doing this should work:

build-wrapper-win-x86-64.exe --out-dir C:\trunk\analyse xc8 -V --pass1 --chip=18F6680 -Q -G --double=24 --float=24 --emi=wordwrite --rom=default,-000-02FF --opt=+asm,+asmfile,-speed,+space,-debug,-local --addrqual=ignore --mode=pro -D_BUILD_FOR_RELEASE -P -N255 --warn=-9 --asmlist -DXPRJ_Build_for_release=Build_for_release --summary=default,-psect,-class,+mem,+hex,-file --codeoffset=0x0300 --checksum=300-FFFD@FFFE --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+download,-config,+clib,-plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto -obuild/action_states.p1 source/action_states.c 

You right it works :slight_smile:

oh but the file becomes:

# (C) SonarSource SA, 2014-2016, contact@sonarsource.com
# All SONARSOURCE programs and content are copyright protected.
# SONARSOURCE and SONARQUBE are trademarks of SonarSource SA. All rights are expressly reserved.
#
# This file is designed exclusively for use with the SONARSOURCE C / C++ / Objective-C Plugin.
# It may not be used in connection with any other software.
# Any other use is prohibited by law and may be grounds for immediate termination of your License.
{
"version":0,
"captures":[
]}

Can you please share the output that you get when you run the command?

Fri Jan 10 16:48:11 2020: build-wrapper, version 3.11 (win-x86-64)
Fri Jan 10 16:48:11 2020: isWow64: 0
Fri Jan 10 16:48:11 2020: windows version: 6.2, service pack: 0.0, build number: 9200, product type: 3
Fri Jan 10 16:48:11 2020: current directory: C:\Jenkins\workspace\OPS_MISRA\trunk
Fri Jan 10 16:48:11 2020: command line received: <xc8 -V --pass1 --chip=18F6680 -Q -G --double=24 --float=24 --emi=wordwrite --rom=default,-000-02FF --opt=+asm,+asmfile,-speed,+space,-debug,-local --addrqual=ignore --mode=pro -D_BUILD_FOR_RELEASE -P -N255 --warn=-9 --asmlist -DXPRJ_Build_for_release=Build_for_release --summary=default,-psect,-class,+mem,+hex,-file --codeoffset=0x0300 --checksum=300-FFFD@FFFE --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+download,-config,+clib,-plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto -obuild/action_states.p1 source/action_states.c -obuild/adc.p1 source/adc.c -obuild/vishay_emulator.p1 source/vishay_emulator.c -obuild/rs232.p1 source/rs232.c -obuild/rs485.p1 source/rs485.c>
Fri Jan 10 16:48:11 2020: initializing json file
Fri Jan 10 16:48:11 2020: starting debug cycle
Fri Jan 10 16:48:11 2020: process created with pid: 8756
Fri Jan 10 16:48:11 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\xc8.exe>
Fri Jan 10 16:48:11 2020: command line: <xc8 -V --pass1 --chip=18F6680 -Q -G --double=24 --float=24 --emi=wordwrite --rom=default,-000-02FF --opt=+asm,+asmfile,-speed,+space,-debug,-local --addrqual=ignore --mode=pro -D_BUILD_FOR_RELEASE -P -N255 --warn=-9 --asmlist -DXPRJ_Build_for_release=Build_for_release --summary=default,-psect,-class,+mem,+hex,-file --codeoffset=0x0300 --checksum=300-FFFD@FFFE --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+download,-config,+clib,-plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto -obuild/action_states.p1 source/action_states.c -obuild/adc.p1 source/adc.c -obuild/vishay_emulator.p1 source/vishay_emulator.c -obuild/rs232.p1 source/rs232.c -obuild/rs485.p1 source/rs485.c>
Fri Jan 10 16:48:11 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:11 2020: isWow64: 1
Fri Jan 10 16:48:11 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\xc8.exe with pid: 8756
Fri Jan 10 16:48:11 2020: process created with pid: 5812
Fri Jan 10 16:48:11 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\picc18.exe>
Fri Jan 10 16:48:11 2020: command line: <"C:\Program Files (x86)\Microchip\xc8\v1.41\bin\picc18" -V --pass1 --chip=18F6680 -Q -G --double=24 --float=24 --emi=wordwrite --rom=default,-000-02FF --opt=+asm,+asmfile,-speed,+space,-debug,-local --addrqual=ignore --mode=pro -D_BUILD_FOR_RELEASE -P -N255 --warn=-9 --asmlist -DXPRJ_Build_for_release=Build_for_release --summary=default,-psect,-class,+mem,+hex,-file --codeoffset=0x0300 --checksum=300-FFFD@FFFE --output=default,-inhx032 --runtime=default,+clear,+init,-keep,-no_startup,+download,-config,+clib,-plib --output=-mcof,+elf:multilocs --stack=compiled:auto:auto:auto -obuild/action_states.p1 source/action_states.c -obuild/adc.p1 source/adc.c -obuild/vishay_emulator.p1 source/vishay_emulator.c -obuild/rs232.p1 source/rs232.c -obuild/rs485.p1 source/rs485.c>
Fri Jan 10 16:48:11 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:11 2020: isWow64: 1
Fri Jan 10 16:48:11 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\picc18.exe with pid: 5812
Fri Jan 10 16:48:11 2020: process created with pid: 7296
Fri Jan 10 16:48:11 2020: image path name: <C:\Windows\SysWOW64\cmd.exe>
Fri Jan 10 16:48:11 2020: command line: <C:\Windows\system32\cmd.exe /c C:\Program" "Files" ("x86)\Microchip\xc8\v1.41\bin\xclm.exe -full-checkout-for-compilers swxc8 1.41 "Jan 24 2017" -hash 74>
Fri Jan 10 16:48:11 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:11 2020: isWow64: 1
Fri Jan 10 16:48:11 2020: skipping process C:\Windows\SysWOW64\cmd.exe with pid: 7296
Fri Jan 10 16:48:11 2020: process created with pid: 8764
Fri Jan 10 16:48:11 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\xclm.exe>
Fri Jan 10 16:48:11 2020: command line: <C:\Program" "Files" ("x86)\Microchip\xc8\v1.41\bin\xclm.exe  -full-checkout-for-compilers swxc8 1.41 "Jan 24 2017" -hash 74>
Fri Jan 10 16:48:11 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:11 2020: isWow64: 1
Fri Jan 10 16:48:11 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\xclm.exe with pid: 8764
Fri Jan 10 16:48:11 2020: process with pid 8764 exit with code: 2 (0x2)
Fri Jan 10 16:48:11 2020: process with pid 7296 exit with code: 2 (0x2)
Fri Jan 10 16:48:11 2020: process created with pid: 11188
Fri Jan 10 16:48:11 2020: image path name: <C:\Windows\SysWOW64\cmd.exe>
Fri Jan 10 16:48:11 2020: command line: <C:\Windows\system32\cmd.exe /c C:\Program" "Files" ("x86)\Microchip\xc8\v1.41\bin\xclm.exe -licenseinfo>
Fri Jan 10 16:48:11 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:11 2020: isWow64: 1
Fri Jan 10 16:48:12 2020: skipping process C:\Windows\SysWOW64\cmd.exe with pid: 11188
Fri Jan 10 16:48:12 2020: process created with pid: 1668
Fri Jan 10 16:48:12 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\xclm.exe>
Fri Jan 10 16:48:12 2020: command line: <C:\Program" "Files" ("x86)\Microchip\xc8\v1.41\bin\xclm.exe  -licenseinfo>
Fri Jan 10 16:48:12 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:12 2020: isWow64: 1
Fri Jan 10 16:48:12 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\xclm.exe with pid: 1668
Fri Jan 10 16:48:12 2020: process with pid 1668 exit with code: 0 (0x0)
Fri Jan 10 16:48:12 2020: process with pid 11188 exit with code: 0 (0x0)
Fri Jan 10 16:48:12 2020: process created with pid: 9120
Fri Jan 10 16:48:12 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe>
Fri Jan 10 16:48:12 2020: command line: <cpp.exe @C:\Users\RALPHD~1\AppData\Local\Temp\cpp_s5lk.cmd>
Fri Jan 10 16:48:12 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:12 2020: isWow64: 1
Fri Jan 10 16:48:12 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe with pid: 9120
Fri Jan 10 16:48:12 2020: process with pid 9120 exit with code: 0 (0x0)
Fri Jan 10 16:48:12 2020: process created with pid: 11204
Fri Jan 10 16:48:12 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe>
Fri Jan 10 16:48:12 2020: command line: <cpp.exe @C:\Users\RALPHD~1\AppData\Local\Temp\cpp_s5lk.cmd>
Fri Jan 10 16:48:12 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:12 2020: isWow64: 1
Fri Jan 10 16:48:12 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe with pid: 11204
Fri Jan 10 16:48:12 2020: process with pid 11204 exit with code: 0 (0x0)
Fri Jan 10 16:48:12 2020: process created with pid: 7272
Fri Jan 10 16:48:12 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\p1.exe>
Fri Jan 10 16:48:12 2020: command line: <p1.exe @C:\Users\RALPHD~1\AppData\Local\Temp\p1_s5lk.cmd>
Fri Jan 10 16:48:12 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:12 2020: isWow64: 1
Fri Jan 10 16:48:12 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\p1.exe with pid: 7272
Fri Jan 10 16:48:12 2020: process with pid 7272 exit with code: 0 (0x0)
Fri Jan 10 16:48:12 2020: process created with pid: 10012
Fri Jan 10 16:48:12 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe>
Fri Jan 10 16:48:12 2020: command line: <cpp.exe @C:\Users\RALPHD~1\AppData\Local\Temp\cpp_s5lk.cmd>
Fri Jan 10 16:48:12 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:12 2020: isWow64: 1
Fri Jan 10 16:48:12 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe with pid: 10012
Fri Jan 10 16:48:12 2020: process with pid 10012 exit with code: 0 (0x0)
Fri Jan 10 16:48:12 2020: process created with pid: 7600
Fri Jan 10 16:48:12 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe>
Fri Jan 10 16:48:12 2020: command line: <cpp.exe @C:\Users\RALPHD~1\AppData\Local\Temp\cpp_s5lk.cmd>
Fri Jan 10 16:48:12 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:12 2020: isWow64: 1
Fri Jan 10 16:48:12 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe with pid: 7600
Fri Jan 10 16:48:13 2020: process with pid 7600 exit with code: 0 (0x0)
Fri Jan 10 16:48:13 2020: process created with pid: 10792
Fri Jan 10 16:48:13 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\p1.exe>
Fri Jan 10 16:48:13 2020: command line: <p1.exe @C:\Users\RALPHD~1\AppData\Local\Temp\p1_s5lk.cmd>
Fri Jan 10 16:48:13 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:13 2020: isWow64: 1
Fri Jan 10 16:48:13 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\p1.exe with pid: 10792
Fri Jan 10 16:48:13 2020: process with pid 10792 exit with code: 0 (0x0)
Fri Jan 10 16:48:13 2020: process created with pid: 5948
Fri Jan 10 16:48:13 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe>
Fri Jan 10 16:48:13 2020: command line: <cpp.exe @C:\Users\RALPHD~1\AppData\Local\Temp\cpp_s5lk.cmd>
Fri Jan 10 16:48:13 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:13 2020: isWow64: 1
Fri Jan 10 16:48:13 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe with pid: 5948
Fri Jan 10 16:48:13 2020: process with pid 5948 exit with code: 0 (0x0)
Fri Jan 10 16:48:13 2020: process created with pid: 8068
Fri Jan 10 16:48:13 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe>
Fri Jan 10 16:48:13 2020: command line: <cpp.exe @C:\Users\RALPHD~1\AppData\Local\Temp\cpp_s5lk.cmd>
Fri Jan 10 16:48:13 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:13 2020: isWow64: 1
Fri Jan 10 16:48:13 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe with pid: 8068
Fri Jan 10 16:48:13 2020: process with pid 8068 exit with code: 0 (0x0)
Fri Jan 10 16:48:13 2020: process created with pid: 10860
Fri Jan 10 16:48:13 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\p1.exe>
Fri Jan 10 16:48:13 2020: command line: <p1.exe @C:\Users\RALPHD~1\AppData\Local\Temp\p1_s5lk.cmd>
Fri Jan 10 16:48:13 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:13 2020: isWow64: 1
Fri Jan 10 16:48:13 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\p1.exe with pid: 10860
Fri Jan 10 16:48:13 2020: process with pid 10860 exit with code: 0 (0x0)
Fri Jan 10 16:48:13 2020: process created with pid: 8264
Fri Jan 10 16:48:13 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe>
Fri Jan 10 16:48:13 2020: command line: <cpp.exe @C:\Users\RALPHD~1\AppData\Local\Temp\cpp_s5lk.cmd>
Fri Jan 10 16:48:13 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:13 2020: isWow64: 1
Fri Jan 10 16:48:13 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe with pid: 8264
Fri Jan 10 16:48:14 2020: process with pid 8264 exit with code: 0 (0x0)
Fri Jan 10 16:48:14 2020: process created with pid: 7192
Fri Jan 10 16:48:14 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe>
Fri Jan 10 16:48:14 2020: command line: <cpp.exe @C:\Users\RALPHD~1\AppData\Local\Temp\cpp_s5lk.cmd>
Fri Jan 10 16:48:14 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:14 2020: isWow64: 1
Fri Jan 10 16:48:14 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe with pid: 7192
Fri Jan 10 16:48:14 2020: process with pid 7192 exit with code: 0 (0x0)
Fri Jan 10 16:48:14 2020: process created with pid: 8652
Fri Jan 10 16:48:14 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\p1.exe>
Fri Jan 10 16:48:14 2020: command line: <p1.exe @C:\Users\RALPHD~1\AppData\Local\Temp\p1_s5lk.cmd>
Fri Jan 10 16:48:14 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:14 2020: isWow64: 1
Fri Jan 10 16:48:14 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\p1.exe with pid: 8652
Fri Jan 10 16:48:14 2020: process with pid 8652 exit with code: 0 (0x0)
Fri Jan 10 16:48:14 2020: process created with pid: 8072
Fri Jan 10 16:48:14 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe>
Fri Jan 10 16:48:14 2020: command line: <cpp.exe @C:\Users\RALPHD~1\AppData\Local\Temp\cpp_s5lk.cmd>
Fri Jan 10 16:48:14 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:14 2020: isWow64: 1
Fri Jan 10 16:48:14 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe with pid: 8072
Fri Jan 10 16:48:14 2020: process with pid 8072 exit with code: 0 (0x0)
Fri Jan 10 16:48:14 2020: process created with pid: 1856
Fri Jan 10 16:48:14 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe>
Fri Jan 10 16:48:14 2020: command line: <cpp.exe @C:\Users\RALPHD~1\AppData\Local\Temp\cpp_s5lk.cmd>
Fri Jan 10 16:48:14 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:14 2020: isWow64: 1
Fri Jan 10 16:48:14 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\cpp.exe with pid: 1856
Fri Jan 10 16:48:14 2020: process with pid 1856 exit with code: 0 (0x0)
Fri Jan 10 16:48:14 2020: process created with pid: 1248
Fri Jan 10 16:48:14 2020: image path name: <C:\Program Files (x86)\Microchip\xc8\v1.41\bin\p1.exe>
Fri Jan 10 16:48:14 2020: command line: <p1.exe @C:\Users\RALPHD~1\AppData\Local\Temp\p1_s5lk.cmd>
Fri Jan 10 16:48:14 2020: working directory: <C:\Jenkins\workspace\OPS_MISRA\trunk\>
Fri Jan 10 16:48:14 2020: isWow64: 1
Fri Jan 10 16:48:15 2020: skipping process C:\Program Files (x86)\Microchip\xc8\v1.41\bin\p1.exe with pid: 1248
Fri Jan 10 16:48:15 2020: process with pid 1248 exit with code: 0 (0x0)
Fri Jan 10 16:48:15 2020: process with pid 5812 exit with code: 0 (0x0)
Fri Jan 10 16:48:15 2020: process with pid 8756 exit with code: 0 (0x0)
Fri Jan 10 16:48:15 2020: finalizing json file
Fri Jan 10 16:48:15 2020: cleaning prober

Does it work with gcc?

build-wrapper-win-x86-64.exe --out-dir C:\trunk\analyse gcc.exe -E -I"test/test" -I"test/test/support" -I"source" -I"C://test/vendor/ceedling/vendor/unity/src" -I"C:/test/vendor/ceedling/vendor/cmock/src" -I"build/test/mocks" -DTEST -D_HOSTED -D_GCC -D_18F6680 -DUNITY_INT_WIDTH=32 -DCMOCK_MEM_INDEX_TYPE=uint64_t -DCMOCK_MEM_PTR_AS_INT=uint64_t -DCMOCK_MEM_SIZE=2056 -DCODE_COVERAGE -DTEST -D_HOSTED -D_18F6680 -DGNU_COMPILER "test/test/test_ascu_init.c" -o "build/test/preprocess/files/test_ascu_init.c"

I have to check but now I got this when I tried all source files to include

C:\Program Files (x86)\Microchip\xc8\v1.41\bin\p1.exe @C:\Users\RALPHD~1\AppData\Local\Temp\p1_s6cg.cmd [ -W-9 "--edf=C:\Program Files (x86)\Microchip\xc8\v1.41\dat\en_msgs.txt" --cmode=htc -Tunsupported,s -Tdeprecated -Taddress,i -QCu,0,const -QN_,0,near -QI_,0,interrupt -QS_,0,persistent -QT_,0,inline -QQ,0,__pack -QR_,0,reentrant -QR_,0,software -QJ_,0,nonreentrant -QJ_,0,compiled -QU,0,__discrete -QAx,0,__minocg -QE_,0,eeprom -QL_,0,low_priority -QH_,0,high_priority -Q00,1512,__invariant -Q00,1512,__stable -QW_s,0,bank0 -QX_s,0,bank1 -QY_s,0,bank2 -QZ_s,0,bank3 -QB_,0,bdata -QFu_,0,far -QPu,0,__rom -QMu,0,__ram -v -N255 -S -u -fp "--cfgdata=C:\Program Files (x86)\Microchip\xc8\v1.41\dat\cfgdata\18f6680.cfgdata" "--cfgmap=C:\Program Files (x86)\Microchip\xc8\v1.41\dat\cfgmap\18f6680.cfgmap" -Gstrings,const -M -B -Y -r -J build\adc.pre build\adc.p1 C:\Users\RALPHD~1\AppData\Local\Temp\s6cg.26 ]
del C:\Users\RALPHD~1\AppData\Local\Temp\cpp_s6cg.cmd
del C:\Users\RALPHD~1\AppData\Local\Temp\p1_s6cg.cmd
(908) exit status = 1

xc8 isn’t currently supported. Let me know if the analysis works with gcc

I will but I never build the code with gcc, so I have to figure it out now :stuck_out_tongue:

Would you know how I can do it?

Oh I making process :slight_smile:

/cygdrive/c/Users/RALPHD~1/AppData/Local/Temp/ccvUDRnw.o:rs232.c:(.text+0x2e52): undefined reference to `get_uint_from_buffer'
/usr/lib/gcc/x86_64-pc-cygwin/7.4.0/../../../../lib/libcygwin.a(libcmain.o): In function `main':
/usr/src/debug/cygwin-3.0.3-1/winsup/cygwin/lib/libcmain.c:37: undefined reference to `WinMain'
collect2: error: ld returned 1 exit status

C:\Jenkins\workspace\OPS_MISRA\trunk>build-wrapper-win-x86-64.exe --out-dir  analyse gcc -D_GCC ./source/rs232.c ./source/xc_library.c

The wrapper dump is not empty. I will try to send it to the server and see if I see something.
I will let you know

it seems to work, now I need to compare it with the community edition if I found now more or less. :stuck_out_tongue:

Great! Make sure you enable all Misra rules. Some of them are disabled by default.

Thanks :slight_smile:
Have a great week,

I will open another topic about C# analysing about unittest details, I think offically its not supported.
But I could make a generic test format execution report and use that in the tests maybe sonarqube takes it. Or is it wasting my time?

I already attached to a existing topic of it listed here
test execution format question c#

I have another question about the source code analysis.

I see that a header file contains a defintion for a function named

uint16_t analog_ophaal();

Remove this unused function.See Rule

But in a other file named adc.c
This function is implemented and used.

So then this code smell is a false positive ?

@Abbas_Sabra
I have another question related to the test source files.
currently I get

16:40:35.132 INFO: Parsing C:\Jenkins\workspace\OPS_MISRA\trunk\SonarQube_Test_Execution_report.xml

16:40:35.149 INFO: Imported test execution data for 0 files

16:40:35.149 INFO: Test execution data ignored for 1 unknown files, including:

tests/test/test_buzzer.c

I think the issue is that i have a root folder with

 root/source
 root/test/test

Sonar scanner I supply with

-Dsonar.source = source
-Dsonar.tests=/test/test/

Maybe it must be sonar.tests=test/test I have to look for it.
But I think the test files dont needs to be misra analyzed but they need to be part of the source somehow to find leads to test report.xml and the tests right?

Something is going wrong here for me :stuck_out_tongue:

edit:
nevermind I got it working lol
Except this is a static generic file with using static forced paths to the code files but it works :slight_smile:

I changed it to
Sonar scanner I supply with

-Dsonar.source = source,test/test
-Dsonar.tests=test/test/

the test xml is

<testExecutions version="1">
  <file path="test/test/test_buzzer.c">
     <testCase name="test_buzzer_on" duration="500">
      <skipped message="short message">other</skipped>
    </testCase>
  </file>  
  <file path="test/test/test_rs232.c">
     <testCase name="test_good_ascu_status_transmit_pending_rs232_transmit_txif_flag_false_and_transmit_shift_register_trmt_false_result" duration="2000"></testCase>
  </file>  
</testExecutions>

but now is my problem that my current generated junit report is named as this xml

<testsuite name="test_buzzer" tests="1" failures="0" skipped="0" time="0.067357">
    <testcase name="test_buzzer_on" />
  </testsuite>

Some how .c is missing and the full path to the testname
Thats some dev work todo to generate a test generic execution format dynamic.

What also is a little bit a bummer is that I cant see tests under a test file
like this I can see

And I can click on it to see the complete source file but not the testcases ?
While the test execution xml contains skipped, failed, tags so the information is there.
why sonarqube cannot render it?

Better to create a new post describing this issue. Always create new post for each new topic/issue.

No, it is probably that the file where this function is used is not analyzed. This is a project-level rule. you should analyze your entire project for it to be working properly. A function that is not used in the analyzed source files is considered unused.

Thank you @Abbas_Sabra
But when I look into the code the file that use the function we talk about it is under the Code Tab in SonarQube and also this file that contains the call of the function contains analysis like code smells and misra bugs.

So that tells me the code is analysed ( all the header and source files )


in main.c that function is called inside a while loop
This main.c file is analysed and code smells are displayed

I need to look at the code to check if it is a false-positive. Can you share the files where it is declared and where it is used? Let me know if they contain private information and you prefer to share them privately.