[ci]: make it easy to run analysis locally (#395)

allows for developers to more easily run the analysis locally before
opening a pull request if they wish.

also disables a noisy warning (bugprone-assignment-in-if-condition)
producing too many false positives.

Reviewed-on: https://codeberg.org/nsxiv/nsxiv/pulls/395
Reviewed-by: Berke Kocaoğlu <kberke@metu.edu.tr>
Co-authored-by: NRK <nrk@disroot.org>
Co-committed-by: NRK <nrk@disroot.org>
This commit is contained in:
NRK 2022-12-02 10:50:15 +00:00 committed by Berke Kocaoğlu
parent 3804b50656
commit 9cb9a54944
3 changed files with 23 additions and 18 deletions

21
etc/woodpecker/analysis.sh Executable file
View file

@ -0,0 +1,21 @@
#!/bin/sh -e
std="c99"
run_cppcheck() {
cppcheck --std="$std" --enable=performance,portability \
--force --quiet --inline-suppr --error-exitcode=1 \
--max-ctu-depth=8 -j"$(nproc)" \
$(make OPT_DEP_DEFAULT="$1" dump_cppflags) \
--suppress=varFuncNullUB --suppress=uninitvar \
*.c
}
run_tidy() {
checks="$(sed '/^#/d' etc/woodpecker/clang-tidy-checks | paste -d ',' -s)"
clang-tidy --warnings-as-errors="*" --checks="$checks" --quiet *.c \
-- -std="$std" $(make OPT_DEP_DEFAULT="$1" dump_cppflags)
}
run_cppcheck "0"; run_cppcheck "1";
run_tidy "0"; run_tidy "1";

View file

@ -8,21 +8,4 @@ pipeline:
imlib2-dev xorgproto \ imlib2-dev xorgproto \
libxft-dev libexif-dev giflib-dev libwebp-dev >/dev/null libxft-dev libexif-dev giflib-dev libwebp-dev >/dev/null
make config.h version.h make config.h version.h
std="c99" ./etc/woodpecker/analysis.sh
run_cppcheck() {
cppcheck --std="$std" --enable=performance,portability \
--force --quiet --inline-suppr --error-exitcode=1 \
--max-ctu-depth=8 -j"$(nproc)" \
$(make OPT_DEP_DEFAULT="$1" dump_cppflags) \
--suppress=varFuncNullUB --suppress=uninitvar \
*.c
}
run_tidy() {
checks="$(sed '/^#/d' etc/woodpecker/clang-tidy-checks | paste -d ',' -s)"
clang-tidy --warnings-as-errors="*" --checks="$checks" --quiet *.c \
-- -std="$std" $(make OPT_DEP_DEFAULT="$1" dump_cppflags)
}
run_cppcheck "0"
run_cppcheck "1"
run_tidy "0"
run_tidy "1"

View file

@ -8,6 +8,7 @@ misc-*,android-cloexec-*,cert-*,llvm-include-order
-bugprone-easily-swappable-parameters,-bugprone-narrowing-conversions,-bugprone-incorrect-roundings -bugprone-easily-swappable-parameters,-bugprone-narrowing-conversions,-bugprone-incorrect-roundings
-bugprone-implicit-widening-of-multiplication-result,-bugprone-integer-division -bugprone-implicit-widening-of-multiplication-result,-bugprone-integer-division
-android-cloexec-fopen,-android-cloexec-pipe,-cert-err33-c -android-cloexec-fopen,-android-cloexec-pipe,-cert-err33-c
-bugprone-assignment-in-if-condition
# false positive warnings # false positive warnings
-clang-analyzer-valist.Uninitialized -clang-analyzer-valist.Uninitialized