2017-07-29 19:28:09 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
cd "$DIR/../../"
|
|
|
|
|
|
|
|
errfile="$DIR/.cppcheck_errors"
|
|
|
|
|
2017-07-30 16:58:19 +08:00
|
|
|
if [ "$1" == "" ]; then
|
|
|
|
mode=diff
|
|
|
|
else
|
|
|
|
mode=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$mode" == diff ]; then
|
|
|
|
files=$( git diff --name-only HEAD~1 HEAD | egrep '^(src|tests|poc)' | egrep '.(hpp|h|cpp)$' )
|
|
|
|
flags=""
|
|
|
|
else
|
|
|
|
files=src/
|
|
|
|
flags="-j$THREADS"
|
|
|
|
fi
|
|
|
|
cppcheck --enable=all --force --suppress=missingInclude $flags -Isrc $files 2>"$errfile"
|
2017-07-29 19:28:09 +08:00
|
|
|
|
|
|
|
cat "$errfile" >&2
|
|
|
|
|
|
|
|
len="$( cat "$errfile" | wc -l )"
|
|
|
|
if [ $len -gt 0 ]; then
|
|
|
|
echo -e "Cppcheck errors:\n$( cat "$errfile" )" > "$errfile"
|
|
|
|
fi
|