scripts/tidy: enable some checks
readability-braces-around-statements is disabled as `={0}` is the only
way (apart from memset) to initialize to zero in C (this is different
in C++).
@@ -8,9 +8,9 @@ set -e
# Exit on pipe fail
set -o pipefail
-RUNCLANGTIDY=${RUNCLANGTIDY:-run-clang-tidy-8}
+CLANGTIDY=${CLANGTIDY:-clang-tidy-8}
-command -v ${RUNCLANGTIDY} >/dev/null 2>&1 || { echo >&2 "${RUNCLANGTIDY} is missing"; exit 1; }
+command -v ${CLANGTIDY} >/dev/null 2>&1 || { echo >&2 "${CLANGTIDY} is missing"; exit 1; }
if ! test -d build; then
echo >&2 "build is not a directory"
@@ -22,4 +22,8 @@ fi
sed -i 's/-mcpu=cortex-m4//g; s/-mfloat-abi=softfp//g; s/-mlong-calls//g; s/-mthumb//g;
s/-Wno-cast-function-type//g; s/-mfpu=fpv4-sp-d16//g' build/compile_commands.json
-${RUNCLANGTIDY} -p build
+# Exclude drivers and external for now. We get the base file set from compile_commands.json, as
+# clang-tidy unfortunately tries to lint a provided source anyway even if it is not part of the
+# build.
+SOURCES=`cat build/compile_commands.json | jq 'map_values(.file) | .[]' | grep -v drivers/ | grep -v external/ | grep -v tools/nanopb/ | xargs echo`
+${CLANGTIDY} -quiet -p build -checks=-*,clang-analyzer-*,-clang-analyzer-cplusplus*,bugprone-*,performance-*,portability-*,readability-*,-readability-braces-around-statements,-readability-magic-numbers,-readability-isolate-declaration,-clang-analyzer-valist.Uninitialized -warnings-as-errors=* -header-filter '.*' ${SOURCES}
