Skip to content

Commit eee8d71

Browse files
committed
Fix linter script.
1 parent c8c4e3c commit eee8d71

File tree

1 file changed

+53
-18
lines changed

1 file changed

+53
-18
lines changed

scripts/run_clang_tidy.sh

Lines changed: 53 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
88
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
99
BUILD_DIR="${1:-${PROJECT_ROOT}/builds/deeplake-pg-dev}"
1010

11+
# Convert BUILD_DIR to absolute path if it's relative
12+
if [[ "$BUILD_DIR" != /* ]]; then
13+
BUILD_DIR="${PROJECT_ROOT}/${BUILD_DIR}"
14+
fi
15+
1116
echo "Running clang-tidy on cpp/deeplake_pg..."
1217
echo "Build directory: ${BUILD_DIR}"
1318

@@ -19,28 +24,58 @@ fi
1924

2025
cd "${PROJECT_ROOT}/cpp/deeplake_pg"
2126

27+
# Create temp directory for parallel output
28+
TEMP_DIR=$(mktemp -d)
29+
trap "rm -rf ${TEMP_DIR}" EXIT
30+
31+
echo "Running clang-tidy in parallel..."
32+
33+
# Run clang-tidy for each file in parallel
34+
for file in *.cpp; do
35+
(
36+
OUTPUT=$(clang-tidy --header-filter='.*deeplake_pg.*' -p "$BUILD_DIR" "$file" 2>&1 || true)
37+
38+
# Count warnings in this file (only in deeplake_pg directory)
39+
FILE_WARNINGS=$(echo "$OUTPUT" | grep -c "deeplake_pg/.*warning:" || true)
40+
# Count errors in this file
41+
FILE_ERRORS=$(echo "$OUTPUT" | grep -c "deeplake_pg/.*error:" || true)
42+
43+
# Save results to temp file
44+
echo "$file|$FILE_WARNINGS|$FILE_ERRORS" > "${TEMP_DIR}/${file}.count"
45+
46+
if [ "$FILE_ERRORS" -gt 0 ]; then
47+
echo "$OUTPUT" | grep "deeplake_pg/.*error:" > "${TEMP_DIR}/${file}.output"
48+
elif [ "$FILE_WARNINGS" -gt 0 ]; then
49+
echo "$OUTPUT" | grep "deeplake_pg/.*warning:" > "${TEMP_DIR}/${file}.output"
50+
fi
51+
) &
52+
done
53+
54+
# Wait for all parallel jobs to complete
55+
wait
56+
57+
echo ""
58+
echo "Processing results..."
59+
2260
WARNINGS=0
2361
ERRORS=0
2462

63+
# Process results in order
2564
for file in *.cpp; do
26-
echo "Checking $file..."
27-
OUTPUT=$(clang-tidy --header-filter='.*deeplake_pg.*' -p "$BUILD_DIR" "$file" 2>&1 || true)
28-
29-
# Count warnings in this file (only in deeplake_pg directory)
30-
FILE_WARNINGS=$(echo "$OUTPUT" | grep -c "deeplake_pg/.*warning:" || true)
31-
# Count errors in this file
32-
FILE_ERRORS=$(echo "$OUTPUT" | grep -c "deeplake_pg/.*error:" || true)
33-
34-
if [ "$FILE_ERRORS" -gt 0 ]; then
35-
echo "$file - has $FILE_ERRORS errors"
36-
echo "$OUTPUT" | grep "deeplake_pg/.*error:"
37-
ERRORS=$((ERRORS + FILE_ERRORS))
38-
elif [ "$FILE_WARNINGS" -gt 0 ]; then
39-
echo "$file - has $FILE_WARNINGS warnings"
40-
echo "$OUTPUT" | grep "deeplake_pg/.*warning:"
41-
WARNINGS=$((WARNINGS + FILE_WARNINGS))
42-
else
43-
echo "$file - no issues"
65+
if [ -f "${TEMP_DIR}/${file}.count" ]; then
66+
IFS='|' read -r fname FILE_WARNINGS FILE_ERRORS < "${TEMP_DIR}/${file}.count"
67+
68+
if [ "$FILE_ERRORS" -gt 0 ]; then
69+
echo "$file - has $FILE_ERRORS errors"
70+
cat "${TEMP_DIR}/${file}.output"
71+
ERRORS=$((ERRORS + FILE_ERRORS))
72+
elif [ "$FILE_WARNINGS" -gt 0 ]; then
73+
echo "$file - has $FILE_WARNINGS warnings"
74+
cat "${TEMP_DIR}/${file}.output"
75+
WARNINGS=$((WARNINGS + FILE_WARNINGS))
76+
else
77+
echo "$file - no issues"
78+
fi
4479
fi
4580
done
4681

0 commit comments

Comments
 (0)