Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

fix(health): leave the hotspot figure out of the headline when there is none (#4295)

Raghav Chamadiya664f7a230b9e
diff --git a/packages/cli/src/repowise/cli/commands/health_cmd/command.py b/packages/cli/src/repowise/cli/commands/health_cmd/command.py
index 2f6357b51..a8329d59a 100644
--- a/packages/cli/src/repowise/cli/commands/health_cmd/command.py
+++ b/packages/cli/src/repowise/cli/commands/health_cmd/command.py
@@ -591,10 +591,13 @@ def _render_headline(kpis: dict[str, Any], code_shape: bool, unanalysed: int) ->
if production is not None and has_tests
else ""
)
+ # A repo with no recent churn has no hotspots, so no hotspot figure.
+ hotspot = kpis.get("hotspot_health")
+ hotspot_str = f"Hotspot: [bold]{hotspot}[/bold]/10 · " if hotspot is not None else ""
console.print(
f"\nCode health: [bold]{avg if avg is not None else '?'}[/bold]/10{band_str} · "
f"{production_str}"
- f"Hotspot: [bold]{kpis.get('hotspot_health') or '?'}[/bold]/10 · "
+ f"{hotspot_str}"
f"Worst: [bold]{kpis.get('worst_performer_score') or '?'}[/bold]/10 "
f"({kpis.get('worst_performer_path') or 'n/a'})"
)
diff --git a/tests/unit/cli/test_health_cmd_controls.py b/tests/unit/cli/test_health_cmd_controls.py
index eb609c5ff..cc316f09a 100644
--- a/tests/unit/cli/test_health_cmd_controls.py
+++ b/tests/unit/cli/test_health_cmd_controls.py
@@ -192,10 +192,21 @@ def test_the_headline_names_production_code_while_tests_are_in_it() -> None:
return console.file.getvalue()
base = {"average_health": 8.0, "production_average": 6.0, "file_count": 2}
- assert "Production code: 6.0/10 · Hotspot: ?/10" in headline(**base, production_file_count=1)
+ assert "Production code: 6.0/10 · Worst:" in headline(**base, production_file_count=1)
# Narrowed to production, the two figures are one.
narrowed = headline(**base, production_file_count=2)
- assert "Production code" not in narrowed and "Hotspot: ?/10" in narrowed
+ assert "Production code" not in narrowed and "[Good] · Worst:" in narrowed
+
+
+def test_the_headline_names_hotspot_health_only_when_there_is_one() -> None:
+ def headline(**kpis) -> str:
+ console = Console(file=io.StringIO(), width=400, force_terminal=False)
+ with patch.object(health_module, "console", console):
+ health_module._render_headline(kpis, False, 0)
+ return console.file.getvalue()
+
+ assert "Hotspot: 6.5/10 · Worst:" in headline(average_health=8.0, hotspot_health=6.5)
+ assert "Hotspot" not in headline(average_health=8.0, hotspot_health=None)
def test_the_performance_line_leads_with_the_causes_worth_fixing_now() -> None: