Different results from sonar-scanner and sonarlint

I am evaluating SonarQube and got a test license from Sonar for the Developer Edition. It is a C++ project using MinGW. I set up a local SonarQube server on my windows machine with the embedded database and use SonarLint in Eclipse. My problem is that the issues I get in SonarQube are different then in SonarLint.
I checked some similar questions in stackoverflow and groups.google but could not get a running setup.

In Sonar Lint I get 83 issues
In Sonar Qube I get 12 issues

This is installed:
sonar-scanner-cli-3.2.0.1227-windows
sonarqube-6.7.4
SonarCFamilyLanguages Code Analyzer for C, C++, Objective-C 5.1 (build 10083)installed
+ several other languages
Windows 10 64Bit

When uploading the data with “sonar-scanner.bat -X” to the server I don’t see ERROR nor WARNING in the results.

This is the command line pattern of eclipse:
build-wrapper-win-x86-64.exe --out-dir bw-output ${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}

This is the structure of my project:

..\DoorApplication\02_CrossDev\
			+ Unittest
			+ TestHelpers
			+ Src
			sonar-project.properties
			.cproject
			.project

..\DoorApplication\01_Source\
			+ Framweork
			+ HAL
			+ Interfaces

This is the sonar-project.properties file:

sonar.host.url=http://172.20.37.69:9000
sonar.projectName=Test project 1
sonar.projectKey=TestProject1_Key
sonar.projectVersion=1.0
sonar.sourceEncoding=UTF-8 

sonar.projectBaseDir=../
sonar.cfamily.build-wrapper-output=Debug/bw-output
sonar.sources=01_Source, 02_CrossDev

Let’s examine just one example:
There is a class 02_CrossDev/TestHelpers/TCPServer/Socket.cpp.
In SonarLint I see 8 major issues, 8 days ago.
In SonarQube I see this file, 168 lines of code but no issues.
In the sonar-scanner.bat output I see 11:19:30.913 DEBUG: ‘02_CrossDev\TestHelpers\TCPServer\Socket.cpp’ indexed with language ‘cpp’

Has somebody an idea what’s wrong?
Thanks for any help.

Hi Konrad,

What is actually executed after substitution of things like ${COMMAND}? And how many build-wrapper executions happens during the build? These questions come from the following facts:

  • executions of build-wrapper are not additive - each subsequent overwrites previous
  • would be analyzed only files that were compiled during latest execution of build-wrapper

Therefore please check that there is only one execution of build-wrapper for the whole build of your project and this build is clean, i.e. compiles all files.

1 Like

Hi Evgeny

That was the problem. I found in the logs that eclipse has called the build-wrapper several times. Unfortunately I couldn’t find a way that eclipse is calling the build-wrapper one time. So I created a batch to call and compile eclipse from the command shell. For all that run into the same problem here is the call:

build-wrapper-win-x86-64.exe --out-dir bw-output eclipsec -nosplash -application org.eclipse.cdt.managedbuilder.core.headlessbuild -import [yourPath] -build [projectName]

Thanks for your help!

1 Like