refactor(verilog): use if let Some in for-loops instead of ?#1155
Conversation
The `?` operator inside a `for` loop short-circuits the entire enclosing function on the first `None`, not just the current iteration. In practice `node.child(i)` returns `Some` for every `i < child_count()`, so this was harmless, but `if let Some(child) = node.child(i)` is more defensively correct and matches the pattern already used in `handle_package_import` and `handle_include_directive`. Closes #1118
|
Claude finished @carlos-alm's task —— View job PR Review: Verilog Extractor Refactor
|
Greptile SummaryThis PR replaces
Confidence Score: 5/5Safe to merge — both changed functions preserve their original branching logic exactly, and the refactored form is consistent with the rest of the file. The refactored code is a straightforward mechanical substitution. The No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[find_class_name or find_class_superclass] --> B[for i in 0 to child_count]
B --> C{node.child i}
C -->|None - skip iteration| B
C -->|Some child| D{child.kind matches target?}
D -->|No| B
D -->|Yes| E[return Some result]
B -->|loop exhausted| F[return None]
Reviews (1): Last reviewed commit: "refactor(verilog): use if let Some in fo..." | Re-trigger Greptile |
Codegraph Impact Analysis2 functions changed → 5 callers affected across 1 files
|

Summary
node.child(i)?insideforloops infind_class_nameandfind_class_superclasswithif let Some(child) = node.child(i).?operator short-circuits the entire enclosing function on the firstNone, not just the current loop iteration. In practicenode.child(i)returnsSomefor everyi < child_count(), so this is harmless today, but theif let Someform is more defensively correct and matches the pattern already used inhandle_package_importandhandle_include_directive.Test plan
cargo test -p codegraph-core --lib extractors::verilog(9/9 pass)cargo check -p codegraph-core(clean)Closes #1118