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(graph): type a Go method whose receiver is unexported (#1676)
Raghav Chamadiyaeb9e9de65c79
diff --git a/packages/core/src/repowise/core/ingestion/extractors/helpers.py b/packages/core/src/repowise/core/ingestion/extractors/helpers.pyindex e59b3edcd..9db170956 100644--- a/packages/core/src/repowise/core/ingestion/extractors/helpers.py+++ b/packages/core/src/repowise/core/ingestion/extractors/helpers.py@@ -15,14 +15,20 @@ def node_text(node: Node | None, src: str) -> str:def extract_go_receiver_type(receiver_text: str) -> str | None:- """Extract 'Calculator' from '(c *Calculator)' or '(c Calculator)'."""+ """Extract 'Calculator' from '(c *Calculator)' or '(c Calculator)'.++ A Go receiver is ``name Type`` or a bare ``Type``, so the type is always+ the last part. Selecting it by position rather than by an uppercase first+ letter is what lets an unexported receiver — ``func (s *startEnd) add()`` —+ carry a parent at all; the export convention says nothing about whether a+ name is a type.+ """text = receiver_text.strip("() ")parts = text.split()- for part in reversed(parts):- clean = part.lstrip("*")- if clean and clean[0].isupper():- return clean- return None+ if not parts:+ return None+ clean = parts[-1].lstrip("*")+ return clean or Nonedef refine_go_type_kind(type_spec_node: Node, src: str) -> str:diff --git a/tests/unit/ingestion/test_go_extractors.py b/tests/unit/ingestion/test_go_extractors.pyindex 4c8f80e3c..7b2230ce4 100644--- a/tests/unit/ingestion/test_go_extractors.py+++ b/tests/unit/ingestion/test_go_extractors.py@@ -63,3 +63,20 @@ class TestGoMethodReceiver:greet = [s for s in result.symbols if s.name == "Greet"]assert greetassert greet[0].parent_name == "User"++ def test_unexported_receiver_type_still_parents_the_method(+ self, parser: ASTParser+ ) -> None:+ """Export status says nothing about whether a name is a type."""+ src = b"package x\n\ntype startEnd struct{}\n\nfunc (s *startEnd) add() {}\n"+ result = parser.parse_file(_file(), src)+ add = [s for s in result.symbols if s.name == "add"]+ assert add+ assert add[0].parent_name == "startEnd"++ def test_unnamed_receiver(self, parser: ASTParser) -> None:+ src = b"package x\n\ntype cache struct{}\n\nfunc (*cache) reset() {}\n"+ result = parser.parse_file(_file(), src)+ reset = [s for s in result.symbols if s.name == "reset"]+ assert reset+ assert reset[0].parent_name == "cache"