File: static_analysis.sh

package info (click to toggle)
osk-sdl 0.67.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 504 kB
  • sloc: cpp: 1,766; sh: 447; makefile: 10
file content (26 lines) | stat: -rwxr-xr-x 715 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
set -e

files=$(find . -name "*.cpp")
out=$(mktemp)
cppcheck_enable="style,warning,performance,unusedFunction"
cppcheck_opts="--template=gcc --inline-suppr --std=c++14 --language=c++ --enable=${cppcheck_enable} "

function oops(){
  echo "*************************************************"
  echo "Found an issue with the source code! Please check"
  echo "the output from cppcheck and resolve all warnings"
  echo "and errors!"
  echo "*************************************************"
  rm $out
  exit 1
}

cppcheck $cppcheck_opts ${files} 2>&1 |tee ${out}

# Check output for any errors or warnings
regex=$(echo $cppcheck_enable,error | sed 's/,/|/g')
grep -q -E "$regex" $out && oops

rm $out
exit 0