MCPcopy
hub / github.com/safishamsi/graphify / _is_file_node

Function _is_file_node

worked/mixed-corpus/raw/analyze.py:11–32  ·  view source on GitHub ↗

Return True if this node is a file-level hub node (e.g. 'client', 'models') or an AST method stub (e.g. '.auth_flow()', '.__init__()'). These are synthetic nodes created by the AST extractor and should be excluded from god nodes, surprising connections, and knowledge gap reporting.

(G: nx.Graph, node_id: str)

Source from the content-addressed store, hash-verified

9
10
11def _is_file_node(G: nx.Graph, node_id: str) -> bool:
12 """
13 Return True if this node is a file-level hub node (e.g. 'client', 'models')
14 or an AST method stub (e.g. '.auth_flow()', '.__init__()').
15
16 These are synthetic nodes created by the AST extractor and should be excluded
17 from god nodes, surprising connections, and knowledge gap reporting.
18 """
19 label = G.nodes[node_id].get("label", "")
20 if not label:
21 return False
22 # File-level hub: label is a filename with a code extension
23 if label.split(".")[-1] in ("py", "ts", "js", "go", "rs", "java", "rb", "cpp", "c", "h"):
24 return True
25 # Method stub: AST extractor labels methods as '.method_name()'
26 if label.startswith(".") and label.endswith("()"):
27 return True
28 # Module-level function stub: labeled 'function_name()' - only has a contains edge
29 # These are real functions but structurally isolated by definition; not a gap worth flagging
30 if label.endswith("()") and G.degree(node_id) <= 1:
31 return True
32 return False
33
34
35def god_nodes(G: nx.Graph, top_n: int = 10) -> list[dict]:

Callers 4

god_nodesFunction · 0.70
_cross_file_surprisesFunction · 0.70
suggest_questionsFunction · 0.70

Calls 1

getMethod · 0.45

Tested by

no test coverage detected