I am struggling with running clang-tidy for my project. I am trying to run clang-tidy for my project for send data to Codacy. I am doing it like this:
clang-tidy $PWD -header-filter=.*,-checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus* | ./codacy-clang-tidy-1.1.1 | \
curl -XPOST -L -H "project-token: $CODACY_PROJECT_TOKEN" \
-H "Content-type: application/json" -d @- \
"https://api.codacy.com/2.0/commit/$TRAVIS_COMMIT/issuesRemoteResults"
curl -XPOST -L -H "project-token: $CODACY_PROJECT_TOKEN" \
-H "Content-type: application/json" \
"https://api.codacy.com/2.0/commit/$TRAVIS_COMMIT/resultsFinal"
But it is complaining that compilation data cannot be found:
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "/home/travis/build/mVento3/Duckvil/build"
No compilation database found in /home/travis/build/mVento3/Duckvil or any parent directory
fixed-compilation-database: Error while opening fixed database: No such file or directory
json-compilation-database: Error while opening JSON database: No such file or directory
I am sure that compile_commands.json is in build directory where I am trying to run clang-tidy.
Main CMakeLists.txt:
cmake_minimum_required(VERSION 3.17)
project(Duckvil)
find_program(CLANG_TIDY_COMMAND NAMES clang-tidy)
if(NOT CLANG_TIDY_COMMAND)
message(WARNING "Could not find clang-tidy!")
set(CMAKE_CXX_CLANG_TIDY "" CACHE STRING "" FORCE)
else()
message(WARNING "Found clang-tidy")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_CLANG_TIDY
clang-tidy;
-header-filter=.*;
-checks=*;
--dump-config > .clang-tidy;
)
endif()
if(WIN32)
add_definitions(-DDUCKVIL_PLATFORM_WINDOWS)
else()
if(UNIX)
add_definitions(-DDUCKVIL_PLATFORM_LINUX)
SET(GCC_COVERAGE_COMPILE_FLAGS "-g -O0 -coverage -fprofile-arcs -ftest-coverage")
SET(GCC_COVERAGE_LINK_FLAGS "-coverage -lgcov")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
endif()
endif()
add_definitions(-DDUCKVIL_OUTPUT="${CMAKE_SOURCE_DIR}/bin")
add_subdirectory(source)
list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure")
ENABLE_TESTING()
add_subdirectory(test)
Do i need to specify some additional option, or I misunderstood something?
EDIT
At second thought, maybe I should not doing it in separate "go", but while generating CMake project?
EDIT2
I came up with this:
./codacy-clang-tidy-1.1.1 < compile_commands.json | \
curl -XPOST -L -H "project-token: ${CODACY_PROJECT_TOKEN}" \
-H "Content-type: application/json" -d @- \
"https://api.codacy.com/2.0/commit/${TRAVIS_COMMIT}/issuesRemoteResults"
curl -XPOST -L -H "project-token: ${CODACY_PROJECT_TOKEN}" \
-H "Content-type: application/json" \
"https://api.codacy.com/2.0/commit/${TRAVIS_COMMIT}/resultsFinal"
Now it is not complaining about database, seems it is sending the data to codacy, but I cannot see anything on codacy... I read through codacy-clang-tidy and it seems it is getting the data from stdin.
Specify the location explicitly using
-p
like-p ${CMAKE_BUILD_DIR}
: