diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 19ca17134a2bd1221bd9cd7cd4116c55a4a27c24..9623a648b12bb24e1e3686bd20eca62f9b35a33f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,9 +38,9 @@ before_script: cppcheck: stage: build before_script: - - apt-get update -qq && apt-get install -y -qq cppcheck + - echo deb http://deb.debian.org/debian sid main > /etc/apt/sources.list + - apt-get update -qq && apt-get -t sid install -y -qq cppcheck - cppcheck --version - - cppcheck --doc script: - ci/cppcheck.sh tags: diff --git a/ci/cppcheck.sh b/ci/cppcheck.sh index dd6aa04326253a2b620c0599a51dc8866a1000fb..65f0f1845ca9d86594f44e0cedb5581787abfb99 100755 --- a/ci/cppcheck.sh +++ b/ci/cppcheck.sh @@ -7,8 +7,28 @@ # $ ci/cppcheck.sh # -echo -e "\033[0;34mRunning cppcheck...\033[0m" +echo -e "\033[0;34mStarting cppcheck...\033[0m" + +echo -e "\033[0;34mRunning cppcheck with default checklist...\033[0m" cd "$(dirname "$0")/.." cppcheck --enable=all --inline-suppr --suppress=unusedFunction --suppress=missingIncludeSystem \ --suppress=noExplicitConstructor --error-exitcode=1 -I inc src test + +echo -e "\033[33mRunning cppcheck with MISRA rule compliance tests...\033[0m" + +# grab the MISRA addon and the cppcheck addon interface from github +curl https://raw.githubusercontent.com/danmar/cppcheck/master/addons/misra.py > misra.py +curl https://raw.githubusercontent.com/danmar/cppcheck/master/addons/cppcheckdata.py > cppcheckdata.py + +# generate dump files (XML representations of AST etc.) for all headers, source files etc. +for file in $(find inc/ src/ -type f) +do + cppcheck --dump $file +done + +# run the MISRA checks against the dumps +for file in $(find inc/ src/ -type f -name "*.dump") +do + python misra.py $file +done \ No newline at end of file