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): filter score_breakdown to defect-dimension findings (#4178)
Abdullah Azmid4e317d3f97a
diff --git a/packages/core/src/repowise/core/analysis/health/aggregation.py b/packages/core/src/repowise/core/analysis/health/aggregation.pyindex 53441017f..79eb3f145 100644--- a/packages/core/src/repowise/core/analysis/health/aggregation.py+++ b/packages/core/src/repowise/core/analysis/health/aggregation.py@@ -26,6 +26,7 @@ from .scoring import (biomarker_weight,deduction_split,destacked,+ dimensions_for,history_cap,is_advisory,severity_deduction,@@ -139,9 +140,7 @@ def module_rollups(if module:buckets.setdefault(str(module), []).append(row)- rows = [- {"module": name, **group_rollup(group, deductions)} for name, group in buckets.items()- ]+ rows = [{"module": name, **group_rollup(group, deductions)} for name, group in buckets.items()]rows.sort(key=lambda row: (row["average_health"], row["module"]))return rows@@ -279,7 +278,9 @@ def _scored_raw(findings: list[Any]) -> list[float]:else finding_raw_deduction(f)for f in findings]- names = [(field(f, "biomarker_type", "") or "", field(f, "function_name", None)) for f in findings]+ names = [+ (field(f, "biomarker_type", "") or "", field(f, "function_name", None)) for f in findings+ ]group_by_function(names, raw)return raw@@ -329,9 +330,11 @@ def score_breakdown(findings: Sequence[Any]) -> dict[str, Any]:Categories are emitted in :data:`CATEGORY_CAPS` order and a category with nofindings is omitted, not zero-filled."""- # Advisory findings deduct nothing; left in, they report a raw deduction- # the file never paid.- kept = [f for f in findings if not is_advisory(field(f, "biomarker_type", None) or "")]+ # Findings outside the defect dimension deduct nothing; left in, they+ # report a raw deduction the file never paid.+ kept = [+ f for f in findings if "defect" in dimensions_for(field(f, "biomarker_type", None) or "")+ ]per_category: dict[str, list[tuple[Any, float]]] = {}for finding, raw in zip(kept, _scored_raw(kept), strict=True):category = biomarker_category(field(finding, "biomarker_type", None))diff --git a/tests/unit/health/test_advisory_dimension.py b/tests/unit/health/test_advisory_dimension.pyindex 7007ecf34..bcc304428 100644--- a/tests/unit/health/test_advisory_dimension.py+++ b/tests/unit/health/test_advisory_dimension.py@@ -207,7 +207,13 @@ def test_score_breakdown_does_not_invent_a_deduction_for_an_advisory_finding():"""from repowise.core.analysis.health.aggregation import score_breakdown- result = score_breakdown([_finding("mock_saturated_test", 0.0, ADVISORY_DIMENSION)])+ result = score_breakdown(+ [+ _finding("mock_saturated_test", 0.0, ADVISORY_DIMENSION),+ _finding("io_in_loop", 0.0, "performance"),+ _finding("sql_select_star", 0.0, "maintainability"),+ ]+ )assert result["categories"] == []assert result["total_deduction"] == 0.0