Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(ingestion): keep capturing attributes after a comment (#3461)
ump45nose97ea2172f6c1
diff --git a/packages/core/src/repowise/core/ingestion/parser.py b/packages/core/src/repowise/core/ingestion/parser.pyindex f89a97ff8..86cadf102 100644--- a/packages/core/src/repowise/core/ingestion/parser.py+++ b/packages/core/src/repowise/core/ingestion/parser.py@@ -874,10 +874,16 @@ def _rust_outer_attributes(def_node: Node, src: str) -> list[str]:def _leading_child_attributes(def_node: Node, node_type: str, opener: str, closer: str, src: str) -> list[str]:- """Inner text of the attribute children leading *def_node*, until the first other child."""+ """Inner text of the attribute children leading *def_node*, until the first other child.++ A comment between attribute lists does not end the run, so an attribute+ placed after one is still recorded.+ """attrs: list[str] = []for child in def_node.children:if child.type != node_type:+ if child.type == "comment":+ continuebreakattr_text = _node_text(child, src).strip()if attr_text.startswith(opener) and attr_text.endswith(closer):diff --git a/tests/unit/ingestion/parser/test_misc.py b/tests/unit/ingestion/parser/test_misc.pyindex 790831e51..17ba1bc0c 100644--- a/tests/unit/ingestion/parser/test_misc.py+++ b/tests/unit/ingestion/parser/test_misc.py@@ -177,3 +177,29 @@ def test_declared_modifiers(result = parser.parse_file(_make_file_info(path, language), source)got = {s.name: s.modifiers for s in result.symbols if s.name in expected}assert got == expected+++_COMMENT_ATTRIBUTE_CASES = (+ (+ "csharp",+ "OrderController.cs",+ b'[Authorize] // admins only\n[Route("orders")]\npublic class OrderController : Controller { }\n',+ {"OrderController": ["Authorize", 'Route("orders")']},+ ),+ (+ "cpp",+ "a.cpp",+ b"[[a]] /* c */ [[b]]\nvoid f() {}\n",+ {"f": ["a", "b"]},+ ),+)++[email protected](("language", "path", "source", "expected"), _COMMENT_ATTRIBUTE_CASES)+def test_attributes_after_a_comment_are_still_leading(+ parser: ASTParser, language: str, path: str, source: bytes, expected: dict+) -> None:+ """A comment between attribute lists does not end the leading attribute run."""+ result = parser.parse_file(_make_file_info(path, language), source)+ got = {s.name: s.decorators for s in result.symbols if s.name in expected}+ assert got == expected