Krolyxon
Commit f23d57d

Branches

Refs →

nsxivf23d57d

[ci]: use cppcheck and clang-tidy for static analysis

Author
NRK
Date
2022-06-15 11:55 +0600
Committer
Gitea · 2022-06-25 08:27 +0200
Parent
658a935
Commit
f23d57d4ada2dbab52e26073d462ebee57cf53a9

+46 −0

3 files changed

  1. A .woodpecker/analysis.yml +27 −0
  2. A .woodpecker/clang-tidy-checks +16 −0
  3. M Makefile +3 −0
A .woodpecker/analysis.yml View
@@ -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"
A .woodpecker/clang-tidy-checks View
@@ -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
M Makefile View
@@ -55,6 +55,9 @@ version.h: config.mk .git/index
5555
5656 .git/index:
5757
58+dump_cppflags:
59+ @echo $(nsxiv_cppflags)
60+
5861 clean:
5962 rm -f *.o nsxiv version.h
6063