Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.
Python aicode-complexitycode-healthcode-intelligencecode-qualitydead-codedeveloper-toolsdocumentationgit-analyticsmcpopen-sourcepythonrefactoringstatic-analysistechnical-debt
fix(health): report no hotspot figure for an empty trend history (#3705)
hassanbd884cc6312e
diff --git a/packages/core/src/repowise/core/analysis/health/trends.py b/packages/core/src/repowise/core/analysis/health/trends.pyindex 7a7093a12..dad02d08f 100644--- a/packages/core/src/repowise/core/analysis/health/trends.py+++ b/packages/core/src/repowise/core/analysis/health/trends.py@@ -197,12 +197,13 @@ def diff_snapshots(history: list[Any]) -> TrendSummary:"""Compare the newest snapshot against the window behind it.*history* is expected oldest-first (the natural insertion order in- ``HealthSnapshot``). Empty history yields a summary with neutral- fields and no alerts.+ ``HealthSnapshot``). Empty history yields a summary with no alerts and a+ null hotspot figure, since nothing was measured. ``current_average_health``+ stays at the neutral 10.0 because the response schema requires a number."""if not history:return TrendSummary(- current_hotspot_health=10.0,+ current_hotspot_health=None,current_average_health=10.0,previous_hotspot_health=None,previous_average_health=None,diff --git a/tests/unit/health/test_trends.py b/tests/unit/health/test_trends.pyindex be703fa34..68cb8a675 100644--- a/tests/unit/health/test_trends.py+++ b/tests/unit/health/test_trends.py@@ -42,9 +42,9 @@ def _series(values: list[float]) -> list[_S]:return [_S(taken_at=_ts(i), hotspot_health=v, average_health=v) for i, v in enumerate(values)]-def test_diff_empty_history_neutral():+def test_diff_empty_history_has_no_hotspot_figure():summary = diff_snapshots([])- assert summary.current_hotspot_health == 10.0+ assert summary.current_hotspot_health is Noneassert summary.hotspot_delta is Noneassert summary.alerts == []