1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/dist/tools/cppcheck/check.sh
2014-09-06 11:27:16 +02:00

28 lines
700 B
Bash
Executable File

#!/bin/sh
BRANCH=${1}
FILEREGEX='\.([sScHh]|cpp)$'
# if branch is an option, unset branch, consume parameter otherwise
if echo "${BRANCH}" | grep -q '^-'; then
BRANCH=""
else
shift 1
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 --diff-filter=ACMR --name-only ${BRANCH} | grep -E ${FILEREGEX})"
fi
if [ -z "${FILES}" ]; then
exit
fi
cppcheck --std=c99 --enable=style --force \
--error-exitcode=2 --inline-suppr --quiet -j 8 \
--template "{file}:{line}: {severity} ({id}): {message}" \
${@} ${FILES}