2014-07-16 13:51:13 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2014-11-19 09:37:07 +01:00
|
|
|
# Don't show warnings about unusedStructMembers by default
|
|
|
|
DEFAULT_SUPPRESSIONS="${1}"
|
|
|
|
if echo "${DEFAULT_SUPPRESSIONS}" | grep -q '^--show-unused-struct'; then
|
|
|
|
DEFAULT_SUPPRESSIONS=""
|
|
|
|
shift 1
|
|
|
|
else
|
|
|
|
DEFAULT_SUPPRESSIONS=--suppress="unusedStructMember"
|
|
|
|
fi
|
|
|
|
|
2014-07-16 13:51:13 +02:00
|
|
|
BRANCH=${1}
|
|
|
|
FILEREGEX='\.([sScHh]|cpp)$'
|
|
|
|
|
2014-10-18 17:14:27 +02:00
|
|
|
# If no branch but an option is given, unset BRANCH.
|
|
|
|
# Otherwise, consume this parameter.
|
2014-07-16 13:51:13 +02:00
|
|
|
if echo "${BRANCH}" | grep -q '^-'; then
|
|
|
|
BRANCH=""
|
|
|
|
else
|
2014-11-21 18:43:26 +01:00
|
|
|
if [ -n "${BRANCH}" ]; then
|
|
|
|
shift 1
|
|
|
|
fi
|
2014-07-16 13:51:13 +02:00
|
|
|
fi
|
|
|
|
|
2014-10-18 17:14:27 +02:00
|
|
|
# If the --diff-filter option is given, consume this parameter.
|
|
|
|
# Set the default DIFFFILTER option otherwise.
|
|
|
|
DIFFFILTER="${1}"
|
|
|
|
if echo "${DIFFFILTER}" | grep -q '^--diff-filter='; then
|
|
|
|
shift 1
|
|
|
|
else
|
|
|
|
DIFFFILTER="--diff-filter=ACMR"
|
|
|
|
fi
|
|
|
|
|
2014-09-06 11:23:32 +02:00
|
|
|
# select either all or only touched-in-branch files, filter through FILEREGEX
|
2014-07-16 13:51:13 +02:00
|
|
|
if [ -z "${BRANCH}" ]; then
|
|
|
|
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})"
|
|
|
|
else
|
2014-10-18 17:14:27 +02:00
|
|
|
FILES="$(git diff ${DIFFFILTER} --name-only ${BRANCH} | grep -E ${FILEREGEX})"
|
2014-07-16 13:51:13 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "${FILES}" ]; then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2014-11-27 08:55:00 +01:00
|
|
|
# TODO: switch back to 8 jobs when/if cppcheck issue is resolved
|
|
|
|
cppcheck --std=c99 --enable=style --force --error-exitcode=2 --quiet -j 1 \
|
2014-11-19 09:37:07 +01:00
|
|
|
--template "{file}:{line}: {severity} ({id}): {message}" \
|
|
|
|
--inline-suppr ${DEFAULT_SUPPRESSIONS} ${@} ${FILES}
|