SonarLint for VSCode - CFamily sensor error

  • Operating system: Windows 10 x64
  • IDE name and flavor/env: VSCode

When trying to use SonarLint in VSCode for Windows, I always get the following error:

I can confirm that I have the compile_commands.json there

I have tried both in connected mode and without connection. Always the same error which results in 0 issues found in the code.

The plugin seems to be loaded correctly:

And when in connected mode the rules seems to be correctly imported from the project in sonarqube.

[Debug - 16:06:51.635]   * cpp: 354 active rules
[Debug - 16:06:51.636] Rule cpp:S5527 is enabled on the server, but not available in SonarLint
[Debug - 16:06:51.636] Rule cpp:S4830 is enabled on the server, but not available in SonarLint
[Debug - 16:06:51.637] Rule common-cpp:DuplicatedBlocks is enabled on the server, but not available in SonarLint
[Debug - 16:06:51.637]   * c: 189 active rules
[Debug - 16:06:51.637] Rule c:S5527 is enabled on the server, but not available in SonarLint
[Debug - 16:06:51.637] Rule c:S4830 is enabled on the server, but not available in SonarLint
[Debug - 16:06:51.638] Rule common-c:DuplicatedBlocks is enabled on the server, but not available in SonarLint

Hi @edsonms,

You can follow this post to get a compilation database without unexpanded files: Getting java.lang.IllegalStateException: unexpanded response file when using SonarLint for VSCode - #3 by Tomasz_Kaminski

Let me know if it works for you.



using the following configuration on my CMakeLists.txt didn’t solve the problem



@edsonms, Did you clean your project and regenerate a compilation database after changing the variable? Did you check the cmake cache to make sure it is set correctly? Try to set these variable at the begining of the CMakeList before your project structure. Also, if you have C files make sure to also set CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES

If you still face an issue after following all of this, can you share the new compilation database?


I have deleted my build folder and reloaded the project, still the same issue. I also moved the set variables to the beginning of my cmakelists, but still the same problem.
See below my cmakelists

cmake_minimum_required(VERSION 3.17) # version can be different

SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")

project(GUnitTestingVSCode) #name of your project

add_subdirectory(googletest) # add googletest subdirectory


include_directories(googletest/include/) # this is so we can #include <gtest/gtest.h>
include_directories(googletest/googlemock/include/gmock/) # this is so we can #include <gmock/gmock.h>

file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_SOURCE_DIR} "../src/*.c" "src/*.cpp" "googletest/*.cpp" )

add_executable(gUnitTest ${SOURCES}) # add this executable

target_link_libraries(gUnitTest PUBLIC gtest gmock gcov) # link google test to this executable

Also please see attached the cmakecache file.

CMakeCache.txt (22.7 KB)

@edsonms, i asked for your new compilation database and not your cmake cache.

If by new compilation database you mean the compile_commands.json I unfortunately can not share it due to private company information. If it is something else, please kindly enlighten me.

Is there any other log that could help find the issue root cause?

@edsonms, yes compile_commands.json is called a compilation database.
The analysis fails because inside of it there is an unexpanded file in the command field( @ followed by a filename). This is unsupported hence the error in your screenshot:
unexpanded response file

The CMake variables that I told you to set should remove these unexpanded files and should make the analysis succeeds ( or at least the error message should change)

That is why I need to look at the compilation database to see if there are still unexpanded files.

Let me know if you want me to send you a private message where you can share the content of your compilation database privately.

Also, can you make sure that you still have the same error in SonarLint logs? Are you pointing in VS Code to the right new compilation database?



After closing, deleting all the build file again and reloading the project somehow it fixed the problem.
Now I can see Sonarlint working. I think the the following lines you passed me for the cmakelists solved the problem

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.