Skip to content

Commit 0e99569

Browse files
committed
Refactor .clang-tidy configuration for improved readability and update local build script to support versioned clang-tidy binaries
1 parent 78c9695 commit 0e99569

2 files changed

Lines changed: 28 additions & 9 deletions

File tree

example_repo/.clang-tidy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Checks: "-*,eigen-avoid-auto"
22
CheckOptions:
3-
- key: eigen-avoid-auto.AllowInRangeFor
4-
value: "false"
5-
- key: eigen-avoid-auto.OnlyExpressions
6-
value: "false"
7-
- key: eigen-avoid-auto.BanDecltypeAuto
8-
value: "true"
3+
- key: eigen-avoid-auto.AllowInRangeFor
4+
value: "false"
5+
- key: eigen-avoid-auto.OnlyExpressions
6+
value: "false"
7+
- key: eigen-avoid-auto.BanDecltypeAuto
8+
value: "true"

tools/test_example_repo_local_build.sh

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,28 @@ EXAMPLE_BUILD_DIR="$EXAMPLE_DIR/build"
2626
cmake -S "$EXAMPLE_DIR" -B "$EXAMPLE_BUILD_DIR"
2727
cmake --build "$EXAMPLE_BUILD_DIR" --target example_repo -- -j"$(nproc)"
2828

29-
CLANG_TIDY_BIN=${CLANG_TIDY:-clang-tidy}
30-
if ! command -v "$CLANG_TIDY_BIN" >/dev/null 2>&1; then
31-
echo "clang-tidy executable '$CLANG_TIDY_BIN' not found in PATH" >&2
29+
CLANG_TIDY_BIN=${CLANG_TIDY:-}
30+
if [[ -z "$CLANG_TIDY_BIN" ]]; then
31+
if command -v clang-tidy >/dev/null 2>&1; then
32+
CLANG_TIDY_BIN=$(command -v clang-tidy)
33+
else
34+
shopt -s nullglob
35+
IFS=: read -r -a path_dirs <<< "$PATH"
36+
versioned_bins=()
37+
for dir in "${path_dirs[@]}"; do
38+
for candidate in "$dir"/clang-tidy-[0-9]*; do
39+
[[ -x "$candidate" ]] && versioned_bins+=("$candidate")
40+
done
41+
done
42+
shopt -u nullglob
43+
if [[ ${#versioned_bins[@]} -gt 0 ]]; then
44+
CLANG_TIDY_BIN=$(printf '%s\n' "${versioned_bins[@]}" | sort -V | tail -n1)
45+
fi
46+
fi
47+
fi
48+
49+
if [[ -z "$CLANG_TIDY_BIN" || ! -x "$CLANG_TIDY_BIN" ]]; then
50+
echo "clang-tidy executable not found in PATH" >&2
3251
exit 1
3352
fi
3453

0 commit comments

Comments
 (0)