Skip to content
Permalink
Browse files

Add scripts/cppcheck.sh

  • Loading branch information
rouault committed Jun 1, 2020
1 parent 729a2f1 commit a54ad8814d8cf0022a4972b0d7f50f5859630049
Showing with 68 additions and 0 deletions.
  1. +68 −0 scripts/cppcheck.sh
@@ -0,0 +1,68 @@
#!/bin/sh

set -eu

SCRIPT_DIR=$(dirname "$0")
case $SCRIPT_DIR in
"/"*)
;;
".")
SCRIPT_DIR=$(pwd)
;;
*)
SCRIPT_DIR=$(pwd)/$(dirname "$0")
;;
esac

LOG_FILE=/tmp/cppcheck_qgis.txt

rm -f ${LOG_FILE}
echo "Checking ${SCRIPT_DIR}/../src ..."

cppcheck --library=qt.cfg --inline-suppr \
--template='{file}:{line},{severity},{id},{message}' \
--enable=all --inconclusive --std=c++11 \
-DPROJ_VERSION_MAJOR=6 \
-USIP_RUN \
-DSIP_TRANSFER= \
-DSIP_TRANSFERTHIS= \
-DSIP_INOUT= \
-DSIP_OUT= \
-j $(nproc) \
${SCRIPT_DIR}/../src \
>>${LOG_FILE} 2>&1 &

PID=$!
while kill -0 $PID 2>/dev/null; do
printf "."
sleep 1
done
echo " done"
if ! wait $PID; then
echo "cppcheck failed"
exit 1
fi

ret_code=0

for category in "error" "style" "performance" "portability"; do
if grep "${category}," ${LOG_FILE} >/dev/null; then
echo "INFO: Issues in '${category}' category found, but not considered as making script to fail:"
grep "${category}," ${LOG_FILE}
echo ""
fi
done

if grep "warning," ${LOG_FILE} >/dev/null; then
echo "ERROR: Issues in 'warning' category found:"
grep "warning," ${LOG_FILE}
echo ""
echo "Warnings check failed !"
ret_code=1
fi

if [ ${ret_code} = 0 ]; then
echo "cppcheck succeeded"
fi

exit ${ret_code}

0 comments on commit a54ad88

Please sign in to comment.
You can’t perform that action at this time.