@@ -8,38 +8,47 @@ ERRORS="*"
88
99# TODO(iphydf): Fix these.
1010ERRORS=" $ERRORS ,-cert-err34-c"
11- ERRORS=" $ERRORS ,-cert-str34-c"
1211ERRORS=" $ERRORS ,-readability-suspicious-call-argument"
1312
13+ # TODO(iphydf): Fix once cimple 0.0.19 is released.
14+ CHECKS=" $CHECKS ,-google-readability-casting"
15+
1416# TODO(iphydf): Fix these.
1517CHECKS=" $CHECKS ,-bugprone-switch-missing-default-case"
16- CHECKS=" $CHECKS ,-misc-include-cleaner"
1718
1819# TODO(iphydf): We might want some of these. For the ones we don't want, add a
1920# comment explaining why not.
2021CHECKS=" $CHECKS ,-clang-analyzer-optin.performance.Padding"
2122CHECKS=" $CHECKS ,-hicpp-signed-bitwise"
22- CHECKS=" $CHECKS ,-readability-function-cognitive-complexity"
2323
2424# TODO(iphydf): Maybe fix these?
25- CHECKS=" $CHECKS ,-bugprone-easily-swappable-parameters"
2625CHECKS=" $CHECKS ,-bugprone-implicit-widening-of-multiplication-result"
2726CHECKS=" $CHECKS ,-bugprone-integer-division"
28- CHECKS=" $CHECKS ,-clang-analyzer-core.NullDereference"
29- CHECKS=" $CHECKS ,-clang-analyzer-valist.Uninitialized"
30- CHECKS=" $CHECKS ,-cppcoreguidelines-avoid-non-const-global-variables"
3127CHECKS=" $CHECKS ,-misc-no-recursion"
3228
29+ # TODO(iphydf): Only happens in bootstrap_daemon. Fix it.
30+ CHECKS=" $CHECKS ,-cppcoreguidelines-avoid-non-const-global-variables"
31+
3332# TODO(iphydf): Probably fix these.
3433CHECKS=" $CHECKS ,-cert-err33-c"
3534CHECKS=" $CHECKS ,-cppcoreguidelines-avoid-magic-numbers"
36- CHECKS=" $CHECKS ,-google-readability-casting"
37- CHECKS=" $CHECKS ,-modernize-macro-to-enum"
3835CHECKS=" $CHECKS ,-readability-magic-numbers"
3936
37+ # TODO(iphydf): We're using a lot of macros for constants. Should we convert
38+ # all of them to enum?
39+ CHECKS=" $CHECKS ,-modernize-macro-to-enum"
40+
4041# Documented disabled checks. We don't want these for sure.
4142# =========================================================
4243
44+ # https://stackoverflow.com/questions/58672959/why-does-clang-tidy-say-vsnprintf-has-an-uninitialized-va-list-argument
45+ CHECKS=" $CHECKS ,-clang-analyzer-valist.Uninitialized"
46+
47+ # We pass a lot of ints around, so many function parameters are some kind of
48+ # int type that can be converted from another int type. We won't be getting
49+ # away from that anytime soon.
50+ CHECKS=" $CHECKS ,-bugprone-easily-swappable-parameters"
51+
4352# Callback handlers often don't use all their parameters. There's
4453# IgnoreVirtual, but that doesn't work for C-style callbacks.
4554CHECKS=" $CHECKS ,-misc-unused-parameters"
@@ -132,27 +141,46 @@ CHECKS="$CHECKS,-misc-static-assert"
132141
133142set -eux
134143
144+ # TODO(iphydf): Add toxav.
145+ DIRS=(
146+ other/bootstrap_daemon/src
147+ other
148+ toxcore
149+ toxcore/events
150+ toxencryptsave
151+ )
152+
153+ copy_files () {
154+ find " ${DIRS[@]} " \
155+ -maxdepth 1 -type d -exec mkdir -p " $1 /{}" \;
156+ find " ${DIRS[@]} " \
157+ -maxdepth 1 -name " *.c" -exec cp " {}" " $1 /{}" \;
158+ }
159+
135160run () {
136161 echo " Running clang-tidy in variant '$* '"
137162 EXTRA_ARGS=(" $@ " )
138163 for i in " ${! EXTRA_ARGS[@]} " ; do
139164 EXTRA_ARGS[$i ]=" --extra-arg=${EXTRA_ARGS[$i]} "
140165 done
141- find \
142- other/bootstrap_daemon/src \
143- other \
144- toxav \
145- toxcore \
146- toxcore/events \
147- toxencryptsave \
166+ ls .clang-tidy
167+ copy_files a
168+ if ! find " ${DIRS[@]} " \
148169 -maxdepth 1 -name " *.c" -print0 \
149170 | xargs -0 -n15 -P" $( nproc) " clang-tidy \
150171 -p=_build \
151172 --extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
152173 " ${EXTRA_ARGS[@]} " \
174+ --fix \
153175 --checks=" $CHECKS " \
154176 --warnings-as-errors=" $ERRORS " \
155- --use-color
177+ --use-color; then
178+ copy_files b
179+ colordiff -ru a b
180+ rm -rf a b
181+ false
182+ fi
183+ rm -rf a
156184}
157185
158186cmake . -B_build -GNinja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
0 commit comments