nsxivf23d57d
[ci]: use cppcheck and clang-tidy for static analysis
+46 −0
3 files changed
- A .woodpecker/analysis.yml +27 −0
- A .woodpecker/clang-tidy-checks +16 −0
- M Makefile +3 −0
| @@ -0,0 +1,27 @@ | |||
| 1 | + | pipeline: | |
| 2 | + | analysis: | |
| 3 | + | image: alpine | |
| 4 | + | when: | |
| 5 | + | branch: master | |
| 6 | + | commands: | | |
| 7 | + | apk add --no-cache build-base cppcheck clang-extra-tools \ | |
| 8 | + | imlib2-dev xorgproto \ | |
| 9 | + | libxft-dev libexif-dev giflib-dev libwebp-dev >/dev/null | |
| 10 | + | make config.h version.h | |
| 11 | + | std="c99" | |
| 12 | + | run_cppcheck() { | |
| 13 | + | cppcheck --std="$std" --enable=performance,portability \ | |
| 14 | + | --force --quiet --inline-suppr --error-exitcode=1 \ | |
| 15 | + | --max-ctu-depth=8 -j"$(nproc)" \ | |
| 16 | + | $(make OPT_DEP_DEFAULT="$1" dump_cppflags) \ | |
| 17 | + | *.c | |
| 18 | + | } | |
| 19 | + | run_tidy() { | |
| 20 | + | checks="$(sed '/^#/d' .woodpecker/clang-tidy-checks | paste -d ',' -s)" | |
| 21 | + | clang-tidy --warnings-as-errors="*" --checks="$checks" --quiet *.c \ | |
| 22 | + | -- -std="$std" $(make OPT_DEP_DEFAULT="$1" dump_cppflags) | |
| 23 | + | } | |
| 24 | + | run_cppcheck "0" | |
| 25 | + | run_cppcheck "1" | |
| 26 | + | run_tidy "0" | |
| 27 | + | run_tidy "1" | |
| @@ -0,0 +1,16 @@ | |||
| 1 | + | # checks | |
| 2 | + | clang-analyzer-*,clang-diagnostic-*,bugprone-*,performance-*,modernize-* | |
| 3 | + | misc-*,readability-*,android-cloexec-*,cert-* | |
| 4 | + | ||
| 5 | + | # silence | |
| 6 | + | -misc-unused-parameters | |
| 7 | + | -bugprone-easily-swappable-parameters,-bugprone-narrowing-conversions,-bugprone-incorrect-roundings | |
| 8 | + | -bugprone-implicit-widening-of-multiplication-result,-bugprone-integer-division | |
| 9 | + | -readability-braces-around-statements,-readability-magic-numbers,-readability-isolate-declaration | |
| 10 | + | -readability-function-cognitive-complexity,-readability-else-after-return | |
| 11 | + | -readability-uppercase-literal-suffix,-readability-avoid-const-params-in-decls | |
| 12 | + | -android-cloexec-fopen,-android-cloexec-pipe | |
| 13 | + | ||
| 14 | + | # false positive warnings | |
| 15 | + | -clang-analyzer-valist.Uninitialized | |
| 16 | + | -misc-no-recursion | |
| @@ -55,6 +55,9 @@ version.h: config.mk .git/index | |||
| 55 | 55 | ||
| 56 | 56 | .git/index: | |
| 57 | 57 | ||
| 58 | + | dump_cppflags: | |
| 59 | + | @echo $(nsxiv_cppflags) | |
| 60 | + | ||
| 58 | 61 | clean: | |
| 59 | 62 | rm -f *.o nsxiv version.h | |
| 60 | 63 | ||