Fix: make clang-tidy lint resilient to missing or broken compile databases#657
Open
chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
Open
Fix: make clang-tidy lint resilient to missing or broken compile databases#657chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
chenshengxin2026 wants to merge 1 commit intohw-native-sys:mainfrom
Conversation
…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>
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_load_compile_databasenow returnsNoneinstead of crashing when acompile_commands.jsonis missing, contains invalid JSON, or cannot be reconfigured_build_file_indexskipsNoneentries gracefully so a single broken target does not block the entire lint runfrom __future__ import annotationsfortuple[...] | Nonesyntax compatibilitySplit out from #642 (UT reorganization) — that PR no longer touches
tests/lint/clang_tidy.py.Test plan
clang_tidy.pystill works with valid compile databases (no behavioral change on happy path)if not file_indexguard (line 194-196) still catches the all-databases-broken case and returns exit code 1🤖 Generated with Claude Code