Browse Source

dist/tools/cppcheck: use changed_files.sh

master
Kaspar Schleiser 6 years ago
parent
commit
9b045c127f
  1. 36
      dist/tools/cppcheck/check.sh

36
dist/tools/cppcheck/check.sh vendored

@ -1,5 +1,6 @@
#!/bin/sh
# Copyright 2017 Kaspar Schleiser <kaspar@schleiser.de>
# Copyright 2014 Ludwig Knüpfer <ludwig.knuepfer@fu-berlin.de>
# Copyright 2014 Hinnerk van Bruinehsen <h.v.bruinehsen@fu-berlin.de>
#
@ -7,6 +8,8 @@
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
. ${RIOTBASE:+${RIOTBASE}/}dist/tools/ci/changed_files.sh
# Don't show warnings about unusedStructMembers by default
DEFAULT_SUPPRESSIONS="${1}"
if echo "${DEFAULT_SUPPRESSIONS}" | grep -q '^--show-unused-struct'; then
@ -16,38 +19,7 @@ else
DEFAULT_SUPPRESSIONS=--suppress="unusedStructMember"
fi
BRANCH=${1}
FILEREGEX='\.([CcHh]|[ch]pp)$'
EXCLUDE='^(.+/include/vendor/)'
# If no branch but an option is given, unset BRANCH.
# Otherwise, consume this parameter.
if echo "${BRANCH}" | grep -q '^-'; then
BRANCH=""
else
if [ -n "${BRANCH}" ]; then
shift 1
fi
fi
# 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
# select either all or only touched-in-branch files, filter through FILEREGEX
if [ -z "${BRANCH}" ]; then
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})"
else
FILES="$(git diff ${DIFFFILTER} --name-only ${BRANCH} | grep -E ${FILEREGEX})"
fi
# filter out negatives
FILES=$(echo "${FILES}" | grep -v -E ${EXCLUDE})
FILES=$(changed_files)
if [ -z "${FILES}" ]; then
exit

Loading…
Cancel
Save