MCPcopy Create free account
hub / github.com/CodeGraphContext/CodeGraphContext / simulate_metrics

Function simulate_metrics

src/codegraphcontext/cli/simulator.py:97–117  ·  view source on GitHub ↗

Measure architectural health metrics (coupling, cohesion, circular dependencies, complexity, and maintainability) of the repository.

(
    path: Optional[str] = typer.Argument(None, help="Path to the directory to simulate. Defaults to the current directory."),
    context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
)

Source from the content-addressed store, hash-verified

95
96@simulate_app.command("metrics")
97def simulate_metrics(
98 path: Optional[str] = typer.Argument(None, help="Path to the directory to simulate. Defaults to the current directory."),
99 context: Optional[str] = typer.Option(None, "--context", "-c", help="Specific context to use"),
100):
101 """
102 Measure architectural health metrics (coupling, cohesion, circular dependencies, complexity, and maintainability) of the repository.
103 """
104 load_cgc_credentials(context)
105 repo_path = get_repo_path(path)
106
107 services = _initialize_services(context)
108 db_manager = services[0]
109
110 try:
111 twin = CodeGraphTwin(repo_path).load_from_db(db_manager)
112 summary = twin.get_metrics_summary()
113 print_metrics(summary, f"Architectural Metrics: {twin.repo_name}")
114 except Exception as e:
115 console.print(f"[bold red]Simulation Error:[/bold red] {e}")
116 finally:
117 db_manager.close_driver()
118
119
120@simulate_app.command("run")

Callers

nothing calls this directly

Calls 9

_initialize_servicesFunction · 0.90
CodeGraphTwinClass · 0.90
load_cgc_credentialsFunction · 0.85
get_repo_pathFunction · 0.85
print_metricsFunction · 0.85
load_from_dbMethod · 0.80
get_metrics_summaryMethod · 0.80
printMethod · 0.80
close_driverMethod · 0.45

Tested by

no test coverage detected