topos.functors.probes.mdg.fan¶
Fan-in / Fan-out Metrics¶
Counts incoming and outgoing CALLS edges for a file and its symbols.
- Mathematical Inspiration:
Fan-in/fan-out is a classic software-engineering measure of module connectivity introduced by Henry & Kafura.
Fan-in: how many other symbols call into this file’s symbols. High fan-in means the module is widely depended upon.
Fan-out: how many external symbols this file’s symbols call. High fan-out means the module has many dependencies.
The product
fan_in * fan_out^2(the Henry-Kafura complexity) is sometimes used as a structural-risk proxy, but we expose the raw counts so the evaluation section can apply its own thresholds.
- class topos.functors.probes.mdg.fan.FanResult(fan_in, fan_out)[source]
Bases:
objectFan-in and fan-out counts for a file.
- fan_in
Number of distinct external symbols calling into this file.
- Type:
- fan_out
Number of distinct external symbols called from this file.
- Type:
- fan_in
- fan_out
- topos.functors.probes.mdg.fan.calculate_fan_in_out(graph, file_node_id, symbol_ids=None)[source]
Calculate fan-in and fan-out for a file node.
Counts distinct external caller/callee symbols connected via
CALLSrelationships to any symbol contained in the file.- Parameters:
graph – The dependency graph.
file_node_id – The ID of the file node to analyse.
symbol_ids – Pre-computed set of all contained symbol IDs (including file_node_id itself). Computed from the graph when not provided.
- Returns:
A
FanResultwith fan-in and fan-out counts.