@@ -249,63 +249,6 @@ else
249
249
fi
250
250
echo ' tile-lang clang-format: Done'
251
251
252
-
253
- # Check if clang-tidy is installed and get the version
254
- if command -v clang-tidy & > /dev/null; then
255
- CLANG_TIDY_VERSION=$( clang-tidy --version | head -n 1 | awk ' {print $3}' )
256
- tool_version_check " clang-tidy" " $CLANG_TIDY_VERSION " " $( grep clang-tidy requirements-dev.txt | cut -d' =' -f3) "
257
- else
258
- echo " clang-tidy not found. Skipping C++ static analysis."
259
- CLANG_TIDY_AVAILABLE=false
260
- fi
261
-
262
- # Function to run clang-tidy
263
- clang_tidy () {
264
- clang-tidy " $@ " -- -std=c++17
265
- }
266
-
267
- # Run clang-tidy on all C/C++ files
268
- clang_tidy_all () {
269
- find . -type f \( -name ' *.c' -o -name ' *.cc' -o -name ' *.cpp' -o -name ' *.h' -o -name ' *.hpp' \) \
270
- -not -path " ./3rdparty/*" -not -path " ./build/*" \
271
- | xargs -I{} clang-tidy -extra-arg-before=-xc++ {} -- -std=c++17
272
- }
273
-
274
- # Run clang-tidy on changed C/C++ files relative to main
275
- clang_tidy_changed () {
276
- if git show-ref --verify --quiet refs/remotes/origin/main; then
277
- BASE_BRANCH=" origin/main"
278
- else
279
- BASE_BRANCH=" main"
280
- fi
281
-
282
- MERGEBASE=" $( git merge-base $BASE_BRANCH HEAD) "
283
-
284
- if ! git diff --diff-filter=ACM --quiet --exit-code " $MERGEBASE " -- ' *.c' ' *.cc' ' *.cpp' ' *.h' ' *.hpp' & > /dev/null; then
285
- git diff --name-only --diff-filter=ACM " $MERGEBASE " -- ' *.c' ' *.cc' ' *.cpp' ' *.h' ' *.hpp' | xargs -I{} clang-tidy -extra-arg-before=-xc++ {} -- -std=c++17
286
- fi
287
- }
288
-
289
- # Add clang-tidy support to the main script logic
290
- echo ' tile-lang clang-tidy: Check Start'
291
-
292
- if [[ " $CLANG_TIDY_AVAILABLE " != false ]]; then
293
- if [[ " $1 " == ' --files' ]]; then
294
- # If --files is given, analyze only the provided files
295
- clang_tidy " ${@: 2} "
296
- elif [[ " $1 " == ' --all' ]]; then
297
- # If --all is given, analyze all eligible C/C++ files
298
- clang_tidy_all
299
- else
300
- # Otherwise, analyze only changed C/C++ files
301
- clang_tidy_changed
302
- fi
303
- else
304
- echo " clang-tidy is not available. Skipping static analysis."
305
- fi
306
-
307
- echo ' tile-lang clang-tidy: Done'
308
-
309
252
# Check if there are any uncommitted changes after all formatting steps.
310
253
# If there are, ask the user to review and stage them.
311
254
if ! git diff --quiet & > /dev/null; then
@@ -326,4 +269,4 @@ if ! git diff --quiet &>/dev/null; then
326
269
exit 1
327
270
fi
328
271
329
- echo ' tile-lang: All checks passed'
272
+ echo ' tile-lang: All checks passed'
0 commit comments