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
@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")
SET(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE ON)
SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES 0)
SET (CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES 0)
project(GUnitTestingVSCode) #name of your project
add_subdirectory(googletest) # add googletest subdirectory
add_compile_definitions(TELEMETRY_DIAGNOSTICS)
add_compile_definitions(GTEST)
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>
include_directories("${CMAKE_SOURCE_DIR}/mocks")
include_directories("${CMAKE_SOURCE_DIR}/"
"${CMAKE_SOURCE_DIR}/inc/")
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
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