From 6424ba0665211b1dbd9ea969804828e65e5d06ad Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Sat, 18 Oct 2014 17:14:27 +0200 Subject: [PATCH 1/2] cppcheck: handle --diff-filter option Add the possibility to the cppcheck script to pass git's `--diff-filter` option. Also improve comments a bit. --- dist/tools/cppcheck/check.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/dist/tools/cppcheck/check.sh b/dist/tools/cppcheck/check.sh index c88a6e04b7..2cb965107b 100755 --- a/dist/tools/cppcheck/check.sh +++ b/dist/tools/cppcheck/check.sh @@ -3,18 +3,28 @@ BRANCH=${1} 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 BRANCH="" else shift 1 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 --diff-filter=ACMR --name-only ${BRANCH} | grep -E ${FILEREGEX})" + FILES="$(git diff ${DIFFFILTER} --name-only ${BRANCH} | grep -E ${FILEREGEX})" fi if [ -z "${FILES}" ]; then From f8b8ef3bab86e256d7e5030a222a01f676c0065a Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Fri, 24 Oct 2014 11:41:38 +0200 Subject: [PATCH 2/2] Travis: let cppcheck fail for new files Change Travis configuration for cppcheck to fail on new files and keep on warning about existing ones. --- .travis.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index b7ea7a4270..224d5d13be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,9 +48,11 @@ script: - make -C ./tests/unittests test BOARD=qemu-i386 - ./dist/tools/licenses/check.sh master # TODO: -# Remove the --error-exitcode=0` when all warnings of cppcheck have been -# taken care of in master. - - ./dist/tools/cppcheck/check.sh master --error-exitcode=0 +# Remove all but `master` parameters to cppcheck (and remove second +# invocation) once all warnings of cppcheck have been taken care of +# in master. + - ./dist/tools/cppcheck/check.sh master --diff-filter=MR --error-exitcode=0 + - ./dist/tools/cppcheck/check.sh master --diff-filter=AC # TODO: # Remove the `AC` argument when all headers have been # taken care of in master.