Prints the metrics summary in a rich formatted table.
(summary: Dict[str, Any], title: str = "Architectural Metrics Summary")
| 29 | |
| 30 | |
| 31 | def print_metrics(summary: Dict[str, Any], title: str = "Architectural Metrics Summary"): |
| 32 | """Prints the metrics summary in a rich formatted table.""" |
| 33 | # Maintainability Panel |
| 34 | score = summary["maintainability_score"] |
| 35 | color = "green" if score >= 80 else "yellow" if score >= 50 else "red" |
| 36 | |
| 37 | console.print(Panel( |
| 38 | f"[bold]Maintainability Score:[/bold] [{color}]{score}/100[/{color}]\n" |
| 39 | f"[bold]Active Nodes:[/bold] {summary['nodes_count']} | [bold]External References:[/bold] {summary['external_nodes_count']} | [bold]Total Edges:[/bold] {summary['edges_count']}\n" |
| 40 | f"[bold]Circular Dependency Groups:[/bold] {summary['circular_dependencies_count']}", |
| 41 | title=title, |
| 42 | border_style=color |
| 43 | )) |
| 44 | |
| 45 | # Circular dependencies |
| 46 | if summary["circular_dependencies_count"] > 0: |
| 47 | console.print("\n[bold red]Circular Dependency Cycles Detected:[/bold red]") |
| 48 | for i, group in enumerate(summary["circular_dependency_groups"], 1): |
| 49 | cycle_str = " -> ".join([f"[cyan]{n['name']}[/cyan]" for n in group]) |
| 50 | cycle_str += f" -> [cyan]{group[0]['name']}[/cyan]" |
| 51 | console.print(f" {i}. {cycle_str}") |
| 52 | |
| 53 | # Services Coupling Table |
| 54 | coupling_table = Table(title="\nServices Boundary Coupling Analysis", show_header=True, header_style="bold magenta") |
| 55 | coupling_table.add_column("Service Name", style="cyan") |
| 56 | coupling_table.add_column("Afferent Coupling (Ca)", justify="right") |
| 57 | coupling_table.add_column("Efferent Coupling (Ce)", justify="right") |
| 58 | coupling_table.add_column("Instability Index (I)", justify="right", style="yellow") |
| 59 | |
| 60 | services_coupling = summary["coupling"]["services"] |
| 61 | for sname, data in services_coupling.items(): |
| 62 | if sname in ("External", "Unknown"): |
| 63 | continue |
| 64 | coupling_table.add_row( |
| 65 | sname, |
| 66 | str(data["ca"]), |
| 67 | str(data["ce"]), |
| 68 | f"{data['instability']:.2f}" |
| 69 | ) |
| 70 | console.print(coupling_table) |
| 71 | |
| 72 | # Services Cohesion Table |
| 73 | cohesion_table = Table(title="\nServices Boundary Cohesion Analysis", show_header=True, header_style="bold magenta") |
| 74 | cohesion_table.add_column("Service Name", style="cyan") |
| 75 | cohesion_table.add_column("Nodes Count", justify="right") |
| 76 | cohesion_table.add_column("Internal Edges", justify="right") |
| 77 | cohesion_table.add_column("Outgoing Edges", justify="right") |
| 78 | cohesion_table.add_column("Cohesion Density", justify="right", style="yellow") |
| 79 | cohesion_table.add_column("Internal Ratio", justify="right", style="green") |
| 80 | |
| 81 | cohesion_data = summary["cohesion"] |
| 82 | for sname, data in cohesion_data.items(): |
| 83 | if sname in ("External", "Unknown"): |
| 84 | continue |
| 85 | cohesion_table.add_row( |
| 86 | sname, |
| 87 | str(data["nodes_count"]), |
| 88 | str(data["internal_edges"]), |
no test coverage detected