Skip to content

Commit 6bf04db

Browse files
authored
Merge pull request #2 from OscarShiang/pre_check
Perform static analysis over git-tracked files only
2 parents 3e2923d + 060d9c6 commit 6bf04db

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/pre-commit.hook

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ CPPCHECK_suppresses="--suppress=missingIncludeSystem \
44
--suppress=unusedFunction:http_parser.c \
55
--suppress=duplicateBreak:http_parser.c \
66
--suppress=shadowVariable:http_parser.c"
7-
CPPCHECK_OPTS="-I. --enable=all --error-exitcode=1 --force $CPPCHECK_suppresses ."
7+
CPPCHECK_OPTS="-I. --enable=all --error-exitcode=1 --force $CPPCHECK_suppresses"
88

99
RETURN=0
1010
CLANG_FORMAT=$(which clang-format)
@@ -76,7 +76,9 @@ do
7676
done
7777

7878
# static analysis
79-
$CPPCHECK $CPPCHECK_OPTS >/dev/null
79+
git ls-tree --full-tree -r --name-only HEAD | \
80+
grep -v compat | grep -E "\.(c|cc|cpp|h|hh|hpp)\$" | \
81+
xargs $CPPCHECK $CPPCHECK_OPTS >/dev/null
8082
if [ $? -ne 0 ]; then
8183
RETURN=1
8284
echo "" >&2

0 commit comments

Comments
 (0)