scripts/tidy: check for jq and other improvements
@@ -9,9 +9,11 @@ set -e
set -o pipefail
CLANGTIDY=${CLANGTIDY:-clang-tidy-8}
-
command -v ${CLANGTIDY} >/dev/null 2>&1 || { echo >&2 "${CLANGTIDY} is missing"; exit 1; }
+JQ=${JQ:-jq}
+command -v ${JQ} >/dev/null 2>&1 || { echo >&2 "${JQ} is missing"; exit 1; }
+
if ! test -d build; then
echo >&2 "build is not a directory"
echo >&2 "please run 'make <target>' before running tidy to generate compile_commands.json"
@@ -25,5 +27,5 @@ sed -i 's/-mcpu=cortex-m4//g; s/-mfloat-abi=softfp//g; s/-mlong-calls//g; s/-mth
# 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`
+SOURCES=$(cat build/compile_commands.json | ${JQ} 'map_values(.file) | .[]' | grep -v -e 'drivers/' -e 'external/' -e '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}
