2014-07-16 13:51:13 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2015-09-27 18:58:30 +02:00
|
|
|
# Copyright 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
|
2014-11-28 18:02:49 +01:00
|
|
|
# Copyright 2014 Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
|
|
|
|
#
|
|
|
|
# This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
# General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
# directory for more details.
|
|
|
|
|
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}
|
2017-03-29 16:06:43 +02:00
|
|
|
FILEREGEX='\.([CcHh]|[ch]pp)$'
|
2017-03-06 18:02:48 +01:00
|
|
|
EXCLUDE='^(.+/include/vendor/)'
|
2014-07-16 13:51:13 +02:00
|
|
|
|
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
|
|
|
|
|
2015-05-22 11:46:36 +02:00
|
|
|
# filter out negatives
|
|
|
|
FILES=$(echo "${FILES}" | grep -v -E ${EXCLUDE})
|
|
|
|
|
2014-07-16 13:51:13 +02:00
|
|
|
if [ -z "${FILES}" ]; then
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2017-03-31 12:04:58 +02:00
|
|
|
cppcheck --std=c99 --enable=style --force --error-exitcode=2 --quiet -j 8 \
|
2014-11-19 09:37:07 +01:00
|
|
|
--template "{file}:{line}: {severity} ({id}): {message}" \
|
|
|
|
--inline-suppr ${DEFAULT_SUPPRESSIONS} ${@} ${FILES}
|