From bb7c6592fcd7273ad3e5ac1b34302d03f61ef1da Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 26 May 2024 12:49:14 +0100 Subject: [PATCH] [CI] Add cppcheck script --- .github/workflows/cppcheck.yml | 8 +++----- extras/cppcheck/cppcheck.sh | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100755 extras/cppcheck/cppcheck.sh diff --git a/.github/workflows/cppcheck.yml b/.github/workflows/cppcheck.yml index 8f3ec3df..43a815ba 100644 --- a/.github/workflows/cppcheck.yml +++ b/.github/workflows/cppcheck.yml @@ -18,10 +18,8 @@ jobs: - name: Install cppcheck run: - | - sudo apt-get update - sudo apt-get install -y cppcheck + - sudo apt-get update + - sudo apt-get install -y cppcheck - name: Run cppcheck - run: - cppcheck src --enable=all --force --inline-suppr --quiet --suppress=ConfigurationNotChecked --suppress=unusedFunction + run: ./extras/cppcheck/cppcheck.sh diff --git a/extras/cppcheck/cppcheck.sh b/extras/cppcheck/cppcheck.sh new file mode 100755 index 00000000..d5906e18 --- /dev/null +++ b/extras/cppcheck/cppcheck.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +file=cppcheck.txt +cppcheck --version +cppcheck src --enable=all --force --inline-suppr --suppress=ConfigurationNotChecked --suppress=unusedFunction --quiet >> $file 2>&1 +echo "Cppcheck finished with exit code $?" + +error=$(grep ": error:" $file | wc -l) +warning=$(grep ": warning:" $file | wc -l) +style=$(grep ": style:" $file | wc -l) +echo "found $error erros, $warning warnings and $style style issues" +if [ $error -gt "0" ] || [ $warning -gt "0" ] || [ $style -gt "0" ] +then + cat $file + exitcode=1 +fi + +rm $file +exit $exitcode