ci-cppcheck.sh 1.88 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/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 "Started: $(date)"
echo "Please Wait ..."

# Run cppcheck and output into file
cppcheck  --enable=all \
          -j4 \
          --quiet \
Jan Möbius's avatar
Jan Möbius committed
25
          -i OpenFlipper/libs_required/OpenMesh \
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
          -i build-release \
          -i build-debug \
          -i .svn \
          -i .git \
          --force \
          -UDOXY_IGNORE_THIS \
          --suppress=unusedPrivateFunction \
          --suppress=ConfigurationNotChecked \
          --suppress=missingIncludeSystem \
          -DOPENMESHDLLEXPORT="" \
          -Umin -Umax -UBMPOSTFIX \
          -DACGDLLEXPORT=""\
          -DDLLEXPORTONLY=""\
          -DDLLEXPORT=""\
          . &> cppcheck.log

echo "Finished: $(date)"

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 25 ]; 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