File: static_checks.sh

package info (click to toggle)
mpich 5.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 251,848 kB
  • sloc: ansic: 1,323,147; cpp: 82,869; f90: 72,420; javascript: 40,763; perl: 28,296; sh: 19,399; python: 16,191; xml: 14,418; makefile: 9,474; fortran: 8,046; java: 4,635; pascal: 352; asm: 324; ruby: 176; awk: 27; lisp: 19; php: 8; sed: 4
file content (37 lines) | stat: -rwxr-xr-x 1,178 bytes parent folder | download | duplicates (4)
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
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash -eEx

source buildlib/tools/common.sh

prepare_build
clang --version
gcc --version
cppcheck --version
${WORKSPACE}/contrib/configure-release

report_dir=$(readlink -f ${WORKDIR}/static_check)
mkdir -p $report_dir
echo "##vso[task.setvariable variable=reportExists]True"
echo "##vso[task.setvariable variable=report_dir]$report_dir"

export PATH="`csclng --print-path-to-wrap`:`cscppc --print-path-to-wrap`:`cswrap --print-path-to-wrap`:$PATH"
export CSCLNG_ADD_OPTS="-Xanalyzer:-analyzer-output=html:-o:$report_dir"
set -o pipefail
make -j`nproc` |& tee $report_dir/compile.log
set +o pipefail

cs_errors="cs.err"
cslinker --quiet $report_dir/compile.log \
    | csgrep --mode=json --path ${WORKSPACE} --strip-path-prefix ${WORKSPACE} \
    | csgrep --mode=json --invert-match --path 'conftest.c' \
    | csgrep --mode=grep --invert-match --event "internal warning" --prune-events=1 \
    > $cs_errors

if [ -s $cs_errors ]; then
    echo "static checkers found errors:"
    cat $cs_errors
    echo "##vso[task.logissue type=error]static checkers found errors"
    echo "##vso[task.complete result=Failed;]"
else
    echo "No errors reported by static checkers"
fi