52 lines
1.8 KiB
Bash
Executable File
52 lines
1.8 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# This script performs a single analysis using cppcheck
|
|
# It is used by the 'make test' target in the buildsystems
|
|
# Usually you should use 'ctest -C cppcheck' rather than calling this script directly
|
|
#
|
|
# Parameters: $1 = Application binary
|
|
# $2 = Source file to process
|
|
# $3..$N = include path parameters (-I dir1 -I dir2 ...)
|
|
|
|
cppcheck_cmd=$1
|
|
source_file=$2
|
|
shift 2
|
|
|
|
tmpfil=`mktemp`
|
|
$cppcheck_cmd $@ --force --enable=all --suppress=unusedFunction $source_file &> $tmpfil
|
|
declare -a ignorere
|
|
ignorere=(\\[/usr.*\\]
|
|
\\[.*petsc.*.h:.*\\]:.*
|
|
\\[\\*\\]
|
|
\\[.*Vec3.h:.*\\]:.*Vec[34]..has.a.constructor.with.1.argument.that.is.not.explicit.
|
|
\\[.*Tensor.h:.*\\]:.*SymmTensor..has.a.constructor.with.1.argument.that.is.not.explicit.
|
|
\\[.*Vec3.h:.*\\]:.*Member.variable..Vec3::v..is.not.initialized.in.the.constructor.
|
|
\\[.*Vec3.h:.*\\]:.*Member.variable..Vec3::v..is.not.assigned.a.value.in..Vec3::operator=..
|
|
\\[.*:1\\]:.*Skipping.configuration
|
|
\\[.*PETScPCPerm.C:.*\\]:.*Variable..shell..is.assigned.a.value.that.is.never.used.
|
|
\\[.*ASMu3D.*.C:.*\\]:.*The.scope.of.the.variable..wr..can.be.reduced.)
|
|
|
|
nmatch=`cat $tmpfil | grep "\[.*\]" | wc -l`
|
|
for RE in ${ignorere[*]}
|
|
do
|
|
nign=`cat $tmpfil | grep "$RE" | wc -l`
|
|
let "nmatch=$nmatch-$nign"
|
|
done
|
|
if test $nmatch -gt 0
|
|
then
|
|
cat $tmpfil
|
|
$cppcheck_cmd $@ -q --xml --xml-version=2 --force --enable=all --suppress=unusedFunction $source_file &> $tmpfil
|
|
if test -f cppcheck-result.xml
|
|
then
|
|
mv cppcheck-result.xml cppcheck-result-old.xml
|
|
xml_grep --wrap results --cond error cppcheck-result-old.xml $tmpfil > cppcheck-result.xml
|
|
else
|
|
mv $tmpfil cppcheck-result.xml
|
|
fi
|
|
rm -f cppcheck-result-old.xml $tmpfil
|
|
exit 1
|
|
fi
|
|
|
|
rm $tmpfil
|
|
exit 0
|