memgraph/tools/apollo/cppcheck

29 lines
602 B
Plaintext
Raw Normal View History

#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR/../../"
errfile="$DIR/.cppcheck_errors"
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"
cat "$errfile" >&2
len="$( cat "$errfile" | wc -l )"
if [ $len -gt 0 ]; then
echo -e "Cppcheck errors:\n$( cat "$errfile" )" > "$errfile"
fi