2017-07-29 19:28:09 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
cd "$DIR/../../"
|
|
|
|
|
2017-11-06 17:05:03 +08:00
|
|
|
tmpfile="$DIR/.cppcheck_errors.tmp"
|
2017-07-29 19:28:09 +08:00
|
|
|
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/
|
2017-07-30 18:15:29 +08:00
|
|
|
flags="-j$THREADS -Isrc"
|
2017-07-30 16:58:19 +08:00
|
|
|
fi
|
2017-11-09 20:46:37 +08:00
|
|
|
|
|
|
|
cat > .cppcheck_suppressions <<EOF
|
|
|
|
// supress all explicit constructor warnings since we use the implicit conversion all over the codebase
|
|
|
|
noExplicitConstructor:src/storage/property_value.hpp
|
|
|
|
noExplicitConstructor:src/query/typed_value.hpp
|
|
|
|
noExplicitConstructor:src/communication/bolt/v1/decoder/decoded_value.hpp
|
|
|
|
|
|
|
|
// suppress antrl warnings
|
|
|
|
variableScope:src/query/frontend/opencypher/generated/CypherParser.h
|
|
|
|
variableScope:src/query/frontend/opencypher/generated/CypherLexer.h
|
|
|
|
variableScope:src/query/frontend/opencypher/generated/CypherParser.cpp
|
|
|
|
|
|
|
|
// supress all warnings of this type in the codebase
|
|
|
|
missingInclude
|
|
|
|
unusedFunction
|
|
|
|
unusedStructMember
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cppcheck --enable=all --inline-suppr --force --suppressions-list=.cppcheck_suppressions $flags $files 2>"$tmpfile"
|
|
|
|
rm .cppcheck_suppressions
|
2017-11-06 17:05:03 +08:00
|
|
|
|
|
|
|
cat "$tmpfile" | grep -v "(information) Unmatched suppression" > "$errfile"
|
|
|
|
rm $tmpfile
|
2017-07-29 19:28:09 +08:00
|
|
|
|
|
|
|
cat "$errfile" >&2
|
|
|
|
|
|
|
|
len="$( cat "$errfile" | wc -l )"
|
|
|
|
if [ $len -gt 0 ]; then
|
2017-08-24 21:03:21 +08:00
|
|
|
echo -e "==== Cppcheck errors: ====\n\n\`\`\`\n$( cat "$errfile" )\n\`\`\`" > "$errfile"
|
2017-07-29 19:28:09 +08:00
|
|
|
fi
|