-
Notifications
You must be signed in to change notification settings - Fork 123
Perform static analysis over git-tracked files only #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Instead of changing the options passed to Cppcheck, I would enforce filtered file listing with the aid of Git objects. |
I add the tracking list generated with command |
scripts/pre-commit.hook
Outdated
@@ -76,6 +75,7 @@ do | |||
done | |||
|
|||
# static analysis | |||
git ls-files *.c > $FILE_LIST |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to the following:
git ls-tree --full-tree -r --name-only HEAD | \
grep -v compat | grep -E "\.(c|cc|cpp|h|hh|hpp)\$" | \
xargs $CPPCHECK $CPPCHECK_OPTS >/dev/null
scripts/pre-commit.hook
Outdated
--suppress=duplicateBreak:http_parser.c \ | ||
--suppress=shadowVariable:http_parser.c" | ||
CPPCHECK_OPTS="-I. --enable=all --error-exitcode=1 --force $CPPCHECK_suppresses ." | ||
FILE_LIST=.include_file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't set FILE_LIST
.
Use |
scripts/pre-commit.hook
Outdated
FILE_LIST=.include_file | ||
|
||
CPPCHECK_suppresses="--suppress=missingIncludeSystem" | ||
CPPCHECK_OPTS="-I. --file-list=$FILE_LIST --enable=all --error-exitcode=1 --force $CPPCHECK_suppresses" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto. Remove --file-list=$FILE_LIST
.
The subject can be changed as
|
Thanks for your advices! |
Cppcheck might fail when trying to check
http_parser.c
Since
http_parser.c
is been ignored from adding intocommit, we don't have to check it in pre-commit stage.
I add CPPCHECK_ignore into
scripts/pre-commit.hook
to prevent Cppcheck from checking it.