Open
Description
my pre-commit file look like:
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 # Use the ref you want to point at
hooks:
- id: trailing-whitespace
- id: check-added-large-files
- repo: https://github.com/pocc/pre-commit-hooks
rev: master
hooks:
- id: clang-format
args: [-i]
- id: clang-tidy
# - id: oclint
# - id: uncrustify
# - id: cppcheck
# - id: cpplint
and it's a cmake c++ projects and I added set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
on my cmakelist.txt
and cmake generate file namedcompile_commands.json
and it`s contain the file c++ src file path.
{
"directory": "/Users/chendongsheng/github/cmake_test/build",
"command": "/usr/bin/clang++ -I/Users/chendongsheng/github/cmake_test/lib1/. -I/Users/chendongsheng/github/cmake_test/lib2/. -g -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -o lib1/CMakeFiles/lib1.dir/aaa.cpp.o -c /Users/chendongsheng/github/cmake_test/lib1/aaa.cpp",
"file": "/Users/chendongsheng/github/cmake_test/lib1/aaa.cpp"
},
but when i try to run pre-commit run --all-files
I got error like:
[WARNING] The 'rev' field of repo 'https://github.com/pocc/pre-commit-hooks' appears to be a mutable reference (moving tag / branch). Mutable references are never updated after first install and are not supported. See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details. Hint: `pre-commit autoupdate` often fixes this.
trim trailing whitespace.................................................Passed
check for added large files..............................................Passed
clang-format.............................................................Passed
clang-tidy...............................................................Failed
- hook id: clang-tidy
- exit code: 1
/Users/chendongsheng/github/cmake_test/app/main.cpp:1:10: error: 'lib1.h' file not found [clang-diagnostic-error]
#include "lib1.h"
^~~~~~~~
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "lib1/aaa.cpp"
No compilation database found in /Users/chendongsheng/github/cmake_test/lib1 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
Running without flags.
Error while trying to load a compilation database:
Could not auto-detect compilation database for file "app/main.cpp"
No compilation database found in /Users/chendongsheng/github/cmake_test/app 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
Running without flags.
1 error generated.
Error while processing /Users/chendongsheng/github/cmake_test/app/main.cpp.
Found compiler error(s).
Metadata
Metadata
Assignees
Labels
No labels