Merge pull request #1840 from LudwigOrtmann/cppcheck-selecta

Travis + cppcheck: let cppcheck fail for new files
This commit is contained in:
Ludwig Ortmann 2014-10-24 05:40:40 -07:00
commit ac150e9a3b
2 changed files with 17 additions and 5 deletions

View File

@ -48,9 +48,11 @@ script:
- make -C ./tests/unittests test BOARD=qemu-i386 - make -C ./tests/unittests test BOARD=qemu-i386
- ./dist/tools/licenses/check.sh master - ./dist/tools/licenses/check.sh master
# TODO: # TODO:
# Remove the --error-exitcode=0` when all warnings of cppcheck have been # Remove all but `master` parameters to cppcheck (and remove second
# taken care of in master. # invocation) once all warnings of cppcheck have been taken care of
- ./dist/tools/cppcheck/check.sh master --error-exitcode=0 # in master.
- ./dist/tools/cppcheck/check.sh master --diff-filter=MR --error-exitcode=0
- ./dist/tools/cppcheck/check.sh master --diff-filter=AC
# TODO: # TODO:
# Remove the `AC` argument when all headers have been # Remove the `AC` argument when all headers have been
# taken care of in master. # taken care of in master.

View File

@ -3,18 +3,28 @@
BRANCH=${1} BRANCH=${1}
FILEREGEX='\.([sScHh]|cpp)$' FILEREGEX='\.([sScHh]|cpp)$'
# if branch is an option, unset branch, consume parameter otherwise # If no branch but an option is given, unset BRANCH.
# Otherwise, consume this parameter.
if echo "${BRANCH}" | grep -q '^-'; then if echo "${BRANCH}" | grep -q '^-'; then
BRANCH="" BRANCH=""
else else
shift 1 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 # select either all or only touched-in-branch files, filter through FILEREGEX
if [ -z "${BRANCH}" ]; then if [ -z "${BRANCH}" ]; then
FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})" FILES="$(git ls-tree -r --full-tree --name-only HEAD | grep -E ${FILEREGEX})"
else else
FILES="$(git diff --diff-filter=ACMR --name-only ${BRANCH} | grep -E ${FILEREGEX})" FILES="$(git diff ${DIFFFILTER} --name-only ${BRANCH} | grep -E ${FILEREGEX})"
fi fi
if [ -z "${FILES}" ]; then if [ -z "${FILES}" ]; then