[CppCheck] use a var for error categories

This commit is contained in:
Julien Cabieces 2022-07-21 16:08:52 +02:00 committed by Nyall Dawson
parent 7238520fa0
commit b9be1a35a4

View File

@ -54,22 +54,22 @@ ret_code=0
cat ${LOG_FILE} | grep -v -e "syntaxError," -e "cppcheckError," > ${LOG_FILE}.tmp
mv ${LOG_FILE}.tmp ${LOG_FILE}
ERROR_CATEGORIES=("clarifyCalculation" "duplicateExpressionTernary" "redundantCondition" "postfixOperator" "functionConst" "unsignedLessThanZero" "duplicateBranch")
# unusedPrivateFunction not reliable enough in cppcheck 1.72 of Ubuntu 16.04
if test "$(cppcheck --version)" != "Cppcheck 1.72"; then
ERROR_CATEGORIES+=("unusedPrivateFunction")
fi
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," -e "unusedPrivateFunction," -e "postfixOperator," -e "functionConst," -e "unsignedLessThanZero," -e "duplicateBranch,"
grep "${category}," ${LOG_FILE} | grep -v `printf -- "-e %s, " "${ERROR_CATEGORIES[@]}" `
echo ""
fi
done
# 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" "postfixOperator" "functionConst" "unsignedLessThanZero" "duplicateBranch" "${UNUSED_PRIVATE_FUNCTION}"; do
for category in "error" "warning" ${ERROR_CATEGORIES[@]}; do
if test "${category}" != ""; then
if grep "${category}," ${LOG_FILE} >/dev/null; then
echo "ERROR: Issues in '${category}' category found:"