toxcore/other/analysis/run-clang-tidy
iphydf 30c939e4ab
cleanup: Fix some clang-tidy warnings and make them errors.
The android warnings are disabled now because they suggest using
linux-only extensions of libc. Useful for android indeed, but we're
targeting non-android and non-linux systems as well.
2021-12-10 15:21:27 +00:00

64 lines
2.3 KiB
Bash
Executable File

#!/bin/sh
CHECKS="*"
CHECKS="$CHECKS,-android-cloexec-accept"
CHECKS="$CHECKS,-android-cloexec-fopen"
CHECKS="$CHECKS,-bugprone-not-null-terminated-result"
CHECKS="$CHECKS,-bugprone-reserved-identifier"
CHECKS="$CHECKS,-bugprone-sizeof-expression"
CHECKS="$CHECKS,-cert-dcl37-c"
CHECKS="$CHECKS,-cert-dcl51-cpp"
CHECKS="$CHECKS,-clang-analyzer-optin.performance.Padding"
CHECKS="$CHECKS,-cppcoreguidelines-avoid-magic-numbers"
CHECKS="$CHECKS,-cppcoreguidelines-init-variables"
CHECKS="$CHECKS,-hicpp-multiway-paths-covered"
CHECKS="$CHECKS,-hicpp-signed-bitwise"
CHECKS="$CHECKS,-llvm-else-after-return"
CHECKS="$CHECKS,-llvmlibc-restrict-system-libc-headers"
CHECKS="$CHECKS,-misc-redundant-expression"
CHECKS="$CHECKS,-misc-unused-parameters"
CHECKS="$CHECKS,-readability-else-after-return"
CHECKS="$CHECKS,-readability-inconsistent-declaration-parameter-name"
CHECKS="$CHECKS,-readability-magic-numbers"
CHECKS="$CHECKS,-readability-redundant-control-flow"
ERRORS="*"
# TODO(iphydf): Maybe fix these? Otherwise don't show them, if they are useless.
ERRORS="$ERRORS,-bugprone-branch-clone"
ERRORS="$ERRORS,-bugprone-integer-division"
ERRORS="$ERRORS,-bugprone-narrowing-conversions"
ERRORS="$ERRORS,-clang-analyzer-core.NonNullParamChecker"
ERRORS="$ERRORS,-clang-analyzer-core.NullDereference"
ERRORS="$ERRORS,-clang-analyzer-optin.portability.UnixAPI"
ERRORS="$ERRORS,-clang-analyzer-unix.Malloc"
ERRORS="$ERRORS,-clang-analyzer-valist.Uninitialized"
ERRORS="$ERRORS,-cppcoreguidelines-avoid-non-const-global-variables"
ERRORS="$ERRORS,-cppcoreguidelines-narrowing-conversions"
ERRORS="$ERRORS,-google-readability-casting"
ERRORS="$ERRORS,-misc-no-recursion"
# TODO(iphydf): Fix these.
ERRORS="$ERRORS,-bugprone-macro-parentheses"
ERRORS="$ERRORS,-bugprone-posix-return"
ERRORS="$ERRORS,-bugprone-signed-char-misuse"
ERRORS="$ERRORS,-cert-err34-c"
ERRORS="$ERRORS,-cert-str34-c"
ERRORS="$ERRORS,-clang-analyzer-security.insecureAPI.strcpy"
ERRORS="$ERRORS,-hicpp-uppercase-literal-suffix"
ERRORS="$ERRORS,-readability-uppercase-literal-suffix"
set -eux
clang-tidy-11 \
-p=_build \
--extra-arg=-DMIN_LOGGER_LEVEL=LOGGER_LEVEL_TRACE \
--checks="$CHECKS" \
--warnings-as-errors="$ERRORS" \
--use-color \
other/bootstrap_daemon/src/*.c \
other/*.c \
toxav/*.c \
toxcore/*.c \
toxencryptsave/*.c \
"$@"