diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 710728f72455414866cf3c194524ab133386fc9a..0dda6c16fc727d06fe0f5861c14407c55523be16 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -41,3 +41,9 @@ clang-c++98-Qt5: tags: - Linux - MultiThreads + +cppcheck: + script: "CI/ci-cppcheck.sh" + tags: + - Linux + - MultiThreads diff --git a/CI/ci-cppcheck.sh b/CI/ci-cppcheck.sh new file mode 100755 index 0000000000000000000000000000000000000000..6ee9aeb4de433b68018ca34f7274e445d28f4faa --- /dev/null +++ b/CI/ci-cppcheck.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# Exit script on any error +set -e + +#===================================== +# Color Settings: +#===================================== +NC='\033[0m' +OUTPUT='\033[0;32m' +WARNING='\033[0;93m' + +echo -e "${OUTPUT}" +echo "==============================================================================" +echo "Running cppcheck" +echo "==============================================================================" +echo -e "${NC}" +echo "Please Wait ..." + +# Run cppcheck and output into file +cppcheck --enable=all \ + -j4 \ + --quiet \ + -i libs_required \ + -i Plugin-MemInfo/procps \ + -i Plugin-PoissonReconstruction \ + -i build-release \ + -i build-debug \ + -i .svn \ + -i .git \ + --force \ + -UDOXY_IGNORE_THIS \ + --suppress=unusedPrivateFunction \ + --suppress=ConfigurationNotChecked \ + --suppressions-list=tests/cppcheck-suppressions.txt \ + --suppress=missingIncludeSystem \ + -DOPENMESHDLLEXPORT="" \ + -Umin -Umax -UBMPOSTFIX \ + -DACGDLLEXPORT=""\ + . +#&> cppcheck.log + + +echo -e "${OUTPUT}" +echo "==============================================================================" +echo "CPPCHECK Messages" +echo "==============================================================================" +echo -e "${NC}" + + +# Echo output to command line for simple analysis via gitlab +cat cppcheck.log + +COUNT=$(wc -l < cppcheck.log ) + +echo -e "${OUTPUT}" +echo "==============================================================================" +echo "CPPCHECK Summary" +echo "==============================================================================" +echo -e "${NC}" + +if [ $COUNT -gt 0 ]; then + echo -e ${WARNING} + echo "Total CPPCHECK error Count is $COUNT, which is too High! CPPCHECK Run failed"; + echo -e "${NC}" + exit 1; +else + echo "Total CPPCHECK error Count is $COUNT ... OK" +fi + + diff --git a/tests/cppcheck-suppressions.txt b/tests/cppcheck-suppressions.txt index 27eea14fd3a4ca767277420c08528fcb621f9d39..90001679cbd5d7afb08c8c6647061445b58035fe 100644 --- a/tests/cppcheck-suppressions.txt +++ b/tests/cppcheck-suppressions.txt @@ -36,3 +36,6 @@ redundantAssignment:OpenFlipper/LicenseManager/LicenseManagerActive.cc:310 // purgedConfiguration purgedConfiguration + +// Missing includes from system libraries +missingIncludeSystem