Skip to content

Fix: make clang-tidy lint resilient to missing or broken compile databases#657

Open
chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
chenshengxin2026:lint/clang-tidy-robustness
Open

Fix: make clang-tidy lint resilient to missing or broken compile databases#657
chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
chenshengxin2026:lint/clang-tidy-robustness

Conversation

@chenshengxin2026
Copy link
Copy Markdown
Contributor

Summary

  • _load_compile_database now returns None instead of crashing when a compile_commands.json is missing, contains invalid JSON, or cannot be reconfigured
  • _build_file_index skips None entries gracefully so a single broken target does not block the entire lint run
  • Adds from __future__ import annotations for tuple[...] | None syntax compatibility

Split out from #642 (UT reorganization) — that PR no longer touches tests/lint/clang_tidy.py.

Test plan

  • Verified clang_tidy.py still works with valid compile databases (no behavioral change on happy path)
  • Verified the if not file_index guard (line 194-196) still catches the all-databases-broken case and returns exit code 1

🤖 Generated with Claude Code

…bases

_load_compile_database now returns None instead of crashing when a
compile_commands.json is missing, contains invalid JSON, or cannot be
reconfigured.  _build_file_index skips those entries gracefully so a
single broken target does not block the entire lint run.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request enhances the error handling in tests/lint/clang_tidy.py when loading compilation databases. Key changes include adding from __future__ import annotations, updating _load_compile_database to return None upon failure (e.g., FileNotFoundError or reconfiguration errors), and modifying _build_file_index to skip entries where the database could not be loaded. I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant