test(cpp): address codecov and sonar reports from #672 (macro guard coverage, complexity)#673
Conversation
…inition guards for reachability
…_function cognitive complexity
There was a problem hiding this comment.
Code Review
This pull request refactors macro definition processing in the C++ frontend to properly handle builtins and command-line macros that lack an associated file. Additionally, it extracts the C++ template child location recording logic in function_ingest.py into a dedicated helper method and introduces new tests covering file-scope macro usage and macro usage outside the repository. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|



Summary
Addresses the two bot reports left unhandled on #672: the Codecov patch-coverage report (9 uncovered lines in
cpp_frontend/frontend.py, 86.36% patch coverage) and the SonarQube new issue (S3776 cognitive complexity).Codecov: 9 flagged lines -> 7 covered, 2 defended
New/extended tests in
test_cpp_frontend_macros.py:int global_limit = MAX_SIZE;) attributes CALLS to the Module, mirroring the module-caller rule.build/both use repo macros; the definition node still registers via the header, but neither use site may carry a CALLS edge. A macro DEFINED underbuild/(rel resolves, no module qn) must not become a node.-DCMDLINE_LIMIT=7and<limits.h>macros are used in source; neither is a node and their uses carry no edges._process_macro_definitionpreviously checked rel/module AFTER_macro_function_qnhad already required them, making that guard unreachable; guards now run in reachability order (no file -> outside repo -> empty body), each exercised by the fixtures.The 2 remaining lines (
_queue_macro_call'slocation.file is Noneandreferenced is Nonereturns) are defensive guards against libclang returning None cursors; no source-level fixture can construct them, and removing them would trade a silent skip for a crash on unusual TUs.SonarQube: S3776 on
_register_functionThe
is_macrobranch added in #672 pushed cognitive complexity to 16 (limit 15). The nested C++ template-location block is extracted into_record_cpp_template_child_location, dropping the function back under the threshold with behavior unchanged.Verification
frontend.pymacro paths: every codecov-flagged line except the two defended guards now covered