ci-cppcheck.sh 1.48 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1
2
#!/bin/bash

Jan Möbius's avatar
Jan Möbius committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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 ..."

Jan Möbius's avatar
Jan Möbius committed
20
# Run cppcheck and output into file
Jan Möbius's avatar
Jan Möbius committed
21
cppcheck --enable=all . -I src -i Doc/ --force --suppress=unusedFunction --suppress=missingIncludeSystem --quiet -Umin -Umax -UBMPOSTFIX -DOPENMESHDLLEXPORT="" &> cppcheck.log
Jan Möbius's avatar
Jan Möbius committed
22

Jan Möbius's avatar
Jan Möbius committed
23
24
25
26
27
28
29
echo -e "${OUTPUT}"
echo "=============================================================================="
echo "CPPCHECK Messages"
echo "=============================================================================="
echo -e "${NC}"


Jan Möbius's avatar
Jan Möbius committed
30
31
32
33
34
# Echo output to command line for simple analysis via gitlab
cat cppcheck.log

COUNT=$(wc -l < cppcheck.log )

Jan Möbius's avatar
Jan Möbius committed
35
36
37
38
39
40
echo -e "${OUTPUT}"
echo "=============================================================================="
echo "CPPCHECK Summary"
echo "=============================================================================="
echo -e "${NC}"

Jan Möbius's avatar
Jan Möbius committed
41
42
43
MAX_COUNT=8

if [ $COUNT -gt $MAX_COUNT ]; then
Jan Möbius's avatar
Jan Möbius committed
44
  echo -e ${WARNING}
Jan Möbius's avatar
Jan Möbius committed
45
  echo "Total CPPCHECK error Count is $COUNT, which is too High (max is $MAX_COUNT)! CPPCHECK Run failed";
Jan Möbius's avatar
Jan Möbius committed
46
  echo -e "${NC}"
Jan Möbius's avatar
Jan Möbius committed
47
48
  exit 1;
else
Jan Möbius's avatar
Jan Möbius committed
49
  echo "Total CPPCHECK error Count is $COUNT ... OK"
Jan Möbius's avatar
Jan Möbius committed
50
51
52
fi