Skip to content
Permalink
Browse files

cppcheck.sh: turn 'unusedPrivateFunction' warnings as errors

  • Loading branch information
rouault authored and nyalldawson committed Jun 14, 2020
1 parent f57ff14 commit ff86fa102731a0be1598e278c1ae41795b472dfd
Showing with 18 additions and 8 deletions.
  1. +18 −8 scripts/cppcheck.sh
@@ -28,6 +28,7 @@ cppcheck --library=qt.cfg --inline-suppr \
-DSIP_TRANSFERTHIS= \
-DSIP_INOUT= \
-DSIP_OUT= \
-DSIP_FACTORY= \
-DCMAKE_SOURCE_DIR="/foo/bar" \
-j $(nproc) \
${SCRIPT_DIR}/../src \
@@ -52,18 +53,27 @@ mv ${LOG_FILE}.tmp ${LOG_FILE}
for category in "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} | grep -v -e "clarifyCalculation," -e "duplicateExpressionTernary," -e "redundantCondition,"
grep "${category}," ${LOG_FILE} | grep -v -e "clarifyCalculation," -e "duplicateExpressionTernary," -e "redundantCondition," -e "unusedPrivateFunction,"
echo ""
fi
done

for category in "error" "warning" "clarifyCalculation" "duplicateExpressionTernary" "redundantCondition"; do
if grep "${category}," ${LOG_FILE} >/dev/null; then
echo "ERROR: Issues in '${category}' category found:"
grep "${category}," ${LOG_FILE}
echo ""
echo "${category} check failed !"
ret_code=1
# unusedPrivateFunction not reliable enough in cppcheck 1.72 of Ubuntu 16.04
if test "$(cppcheck --version)" = "Cppcheck 1.72"; then
UNUSED_PRIVATE_FUNCTION=""
else
UNUSED_PRIVATE_FUNCTION="unusedPrivateFunction"
fi

for category in "error" "warning" "clarifyCalculation" "duplicateExpressionTernary" "redundantCondition" "${UNUSED_PRIVATE_FUNCTION}"; do
if test "${category}" != ""; then
if grep "${category}," ${LOG_FILE} >/dev/null; then
echo "ERROR: Issues in '${category}' category found:"
grep "${category}," ${LOG_FILE}
echo ""
echo "${category} check failed !"
ret_code=1
fi
fi
done

0 comments on commit ff86fa1

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