Hello,
using sonarlint 3.4.0 on VSCode 1.66.0, I get an error that sonarlint doesn’t find a header file while it’s present in my project.
From what I found, it happens when the compilation database contains command with options -I with the quote character ’ :
{
"directory": "/data/aqm/Commons",
"file": "src/Action/AqValidation.cpp",
"command": "g++ -Wall -Wmissing-field-initializers -D_AMD_UNIX_ -D_AMD_UNIX_LINUX_ -D__STDC_LIMIT_MACROS -D_AMD_ENV_64_ -D_AMD_GNU_ -D_AMD_DEBUG_ -D_AMD_THREADS_ -D_AMD_THREADS_POSIX_ -D_THREAD_SAFE -D_REENTRANT -D_AMD_DYNLINK_ -D_MWDFIELDS_NO_INLINE_ -DRFD_DB_SQLITE -D_AMD_TRACE_ -DAMD_TRACE=1 -fexceptions -D_AMD_TRACE_ -D_AMD_TRACE_ -D_SBR_MODEL_UNIX_ -D_SBR_MODEL_UNIX_ '-I/remote/tmp/weekly/fop_replicate/osp/Boost/18-0-0-39/include' '-I/data/aqm/Commons/include' -Wall -Werror -Wno-error=deprecated-declarations -g -std=gnu++17 -m64 -pipe -fno-strict-aliasing -fdiagnostics-color=always -fno-pic -fPIC -fno-lto -ffat-lto-objects -fno-plt -fno-semantic-interposition -fexceptions -Wall -fno-strict-aliasing -Wno-comment -Wall -fno-strict-aliasing -Wno-comment -Wall -fno-strict-aliasing -Wno-comment -Wall -fno-strict-aliasing -Wno-comment -MD -MF '/data/aqm/Commons/bmstmp/build/obj/x86_64-2.6.32-v4/DebugSharedGccNoInstr/main/rootSymlink/src/Action/AqValidation.cpp.fullDependencies' -o '/data/aqm/Commons/bmstmp/build/obj/x86_64-2.6.32-v4/DebugSharedGccNoInstr/main/rootSymlink/src/Action/AqValidation.cpp.o' -c src/Action/AqValidation.cpp"
},
This file is present: /data/aqm/Commons/include/Action/AqValidation.hpp
the compilation command contains: ‘-I/data/aqm/Commons/include’
but sonarlint reports this error on the line: #include “Action/AqValidation.hpp”
[{
“resource”: “/data/aqm/Commons/src/Action/AqValidation.cpp”,
“owner”: “sonarlint”,
“code”: “cpp:S2260”,
“severity”: 4,
“message”: “‘Action/AqValidation.hpp’ file not found”,
“source”: “sonarlint”,
“startLineNumber”: 9,
“startColumn”: 1,
“endLineNumber”: 9,
“endColumn”: 35
}]
If I change the command in the compilation database to remove the quote character (-I/data/aqm/Commons/include), sonarlint doesn’t report this error anymore.