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.

feat(health): per-function coverage, the CRAP score and an untested_complexity finding (#4326)

Raghav Chamadiyac1120cf85caa
diff --git a/packages/core/src/repowise/core/analysis/finding_registry.py b/packages/core/src/repowise/core/analysis/finding_registry.py
index 108c75f5a..ccb305ff3 100644
--- a/packages/core/src/repowise/core/analysis/finding_registry.py
+++ b/packages/core/src/repowise/core/analysis/finding_registry.py
@@ -91,6 +91,13 @@ REGISTRY: dict[str, FindingTypeStatus] = {
measured_on="2026-09-29",
reason="Flags duplicated import blocks and data literals as design duplication.",
),
+ # New and unmeasured. Measured CRAP is arithmetic over the report, but an
+ # estimate rests on call-graph reach, whose recall is partial; flip to
+ # validated once a labelled sample clears the floor.
+ "untested_complexity": FindingTypeStatus(
+ "provisional",
+ reason="Not yet measured; estimated coverage rests on call-graph reach.",
+ ),
}
diff --git a/packages/core/src/repowise/core/analysis/health/biomarker_labels.py b/packages/core/src/repowise/core/analysis/health/biomarker_labels.py
index 805cecb93..52281052e 100644
--- a/packages/core/src/repowise/core/analysis/health/biomarker_labels.py
+++ b/packages/core/src/repowise/core/analysis/health/biomarker_labels.py
@@ -19,6 +19,7 @@ BIOMARKER_LABELS: dict[str, str] = {
"dry_violation": "DRY violation",
"untested_hotspot": "Untested hotspot",
"coverage_gap": "Coverage gap",
+ "untested_complexity": "Untested complexity",
"coverage_gradient": "Coverage gradient",
"developer_congestion": "Many authors",
"knowledge_loss": "Fading ownership",
diff --git a/packages/core/src/repowise/core/analysis/health/biomarkers/base.py b/packages/core/src/repowise/core/analysis/health/biomarkers/base.py
index 4c39dd289..52a637868 100644
--- a/packages/core/src/repowise/core/analysis/health/biomarkers/base.py
+++ b/packages/core/src/repowise/core/analysis/health/biomarkers/base.py
@@ -70,6 +70,9 @@ class FileContext:
branch_coverage_pct: float | None = None
covered_lines: set[int] = field(default_factory=set)
total_coverable_lines: int = 0
+ # The lines the report calls executable, hit or not. Empty when the report
+ # did not say, which leaves per-function coverage unmeasured.
+ coverable_lines: set[int] = field(default_factory=set)
# Only a docstring, imports and export lists: no code for coverage to measure.
reexport_only: bool = False
# Duplication signals (populated when the engine ran the
@@ -129,6 +132,9 @@ class FileContext:
# a file's same-named functions, which is the collision #2408 removed.
# Empty without a call graph, which leaves the marker as it was.
cross_file_oracle_lines: frozenset[int] = frozenset()
+ # Start line of each function a test reaches on the call graph, to the call
+ # hops of the nearest such test (1: a test calls it). Empty without a graph.
+ function_test_hops: dict[int, int] = field(default_factory=dict)
@property
def is_test_material(self) -> bool:
diff --git a/packages/core/src/repowise/core/analysis/health/biomarkers/registry.py b/packages/core/src/repowise/core/analysis/health/biomarkers/registry.py
index f059f5ae2..851dc3ae5 100644
--- a/packages/core/src/repowise/core/analysis/health/biomarkers/registry.py
+++ b/packages/core/src/repowise/core/analysis/health/biomarkers/registry.py
@@ -64,6 +64,7 @@ from .sql_select_star import SqlSelectStarDetector
from .sql_update_delete_without_where import SqlUpdateDeleteWithoutWhereDetector
from .string_concat_in_loop import StringConcatInLoopDetector
from .unbounded_read_reduced_in_memory import UnboundedReadReducedInMemoryDetector
+from .untested_complexity import UntestedComplexityDetector
from .untested_hotspot import UntestedHotspotDetector
_DETECTOR_FACTORIES: list[type[Biomarker]] = [
@@ -78,6 +79,7 @@ _DETECTOR_FACTORIES: list[type[Biomarker]] = [
DryViolationDetector, # type: ignore[list-item]
UntestedHotspotDetector, # type: ignore[list-item]
CoverageGapDetector, # type: ignore[list-item]
+ UntestedComplexityDetector, # type: ignore[list-item]
CoverageGradientDetector, # type: ignore[list-item]
DeveloperCongestionDetector, # type: ignore[list-item]
KnowledgeLossDetector, # type: ignore[list-item]
diff --git a/packages/core/src/repowise/core/analysis/health/biomarkers/untested_complexity.py b/packages/core/src/repowise/core/analysis/health/biomarkers/untested_complexity.py
new file mode 100644
index 000000000..f8bb37025
--- /dev/null
+++ b/packages/core/src/repowise/core/analysis/health/biomarkers/untested_complexity.py
@@ -0,0 +1,103 @@
+"""Untested Complexity — a function whose CRAP score reaches 30.
+
+CRAP weighs a function's cyclomatic complexity by how little of it the tests
+run (:mod:`..crap`). Coverage is measured from the file's coverage report when
+its line sets can say; otherwise it is the function's tier (a test calls it,
+tests reach it, or neither), and the finding says so and never quotes a
+percentage. Severity: medium from 30, high from 50, critical from 100, the
+upper bands for measured coverage only. A function with complexity of 30 or
+more stays above the bar at full coverage, so its finding asks for a
+refactor rather than tests. Test files are exempt.
+"""
+
+from __future__ import annotations
+
+from ..complexity.dispatch import judged_ccn
+from ..crap import CRAP_THRESHOLD, coverage_tier, function_coverage, function_crap
+from ..models import Severity
+from .base import BiomarkerResult, FileContext
+
+_HIGH = 50.0
+_CRITICAL = 100.0
+
+_TIER_TEXT = {
+ "direct": "a test calls it",
+ "reached": "tests reach it",
+ "none": "no test found reaching it",
+}
+
+
+def _severity(crap: float, measured: bool) -> Severity:
+ if measured and crap >= _CRITICAL:
+ return Severity.CRITICAL
+ if measured and crap >= _HIGH:
+ return Severity.HIGH
+ return Severity.MEDIUM
+
+
+def _measured(ctx: FileContext) -> list[float | None]:
+ """Each function's measured coverage, all ``None`` when the report cannot say."""
+ functions = ctx.all_functions
+ if ctx.line_coverage_pct is None:
+ return [None] * len(functions)
+ # A file the report ran none of: every function in it is at 0%.
+ if ctx.line_coverage_pct == 0 and not ctx.covered_lines and ctx.total_coverable_lines > 0:
+ return [0.0] * len(functions)
+ return function_coverage(
+ [(fn.start_line, fn.end_line) for fn in functions],
+ ctx.covered_lines,
+ ctx.coverable_lines or None,
+ )
+
+
+class UntestedComplexityDetector:
+ name = "untested_complexity"
+ category = "test_coverage"
+
+ def detect(self, ctx: FileContext) -> list[BiomarkerResult]:
+ if ctx.is_test_material or ctx.reexport_only or not ctx.all_functions:
+ return []
+ out: list[BiomarkerResult] = []
+ for fn, measured in zip(ctx.all_functions, _measured(ctx), strict=True):
+ ccn = judged_ccn(fn)
+ tier = coverage_tier(
+ ctx.function_test_hops.get(fn.start_line),
+ ctx.reached_by_tests or ctx.has_test_file,
+ )
+ result = function_crap(ccn, measured, tier)
+ if result.crap < CRAP_THRESHOLD:
+ continue
+ is_measured = result.basis == "measured"
+ refactor = ccn >= CRAP_THRESHOLD
+ details: dict = {
+ "crap": round(result.crap, 1),
+ "ccn": fn.ccn,
+ "coverage_basis": result.basis,
+ "action": "refactor" if refactor else "add_tests",
+ }
+ if ccn != fn.ccn:
+ details["judged_ccn"] = ccn
+ if is_measured:
+ details["coverage_pct"] = result.coverage_pct
+ covered = f"{result.coverage_pct:.0f}% of its lines covered"
+ else:
+ details["coverage_tier"] = result.tier
+ covered = f"estimated, {_TIER_TEXT[tier]}"
+ reason = f"{fn.name} has CRAP {result.crap:.0f} (complexity {ccn}, {covered})"
+ if refactor:
+ reason += "; full coverage would not bring it under 30, so simplify it"
+ out.append(
+ BiomarkerResult(
+ biomarker_type=self.name,
+ severity=_severity(result.crap, is_measured),
+ function_name=fn.name,
+ line_start=fn.start_line,
+ line_end=fn.end_line,
+ details=details,
+ reason=reason,
+ )
+ )
+ return out
+
+
+BIOMARKER = UntestedComplexityDetector()
diff --git a/packages/core/src/repowise/core/analysis/health/coverage/model.py b/packages/core/src/repowise/core/analysis/health/coverage/model.py
index 4d27ec713..dc17f1e42 100644
--- a/packages/core/src/repowise/core/analysis/health/coverage/model.py
+++ b/packages/core/src/repowise/core/analysis/health/coverage/model.py
@@ -96,6 +96,7 @@ def coverage_map_entry(fc: FileCoverage, source_format: str | None) -> dict:
"branch_coverage_pct": fc.branch_coverage_pct,
"covered_lines": list(fc.covered_lines),
"total_coverable_lines": fc.total_coverable_lines,
+ "coverable_lines": list(fc.coverable_lines),
"source_format": source_format,
}
diff --git a/packages/core/src/repowise/core/analysis/health/crap.py b/packages/core/src/repowise/core/analysis/health/crap.py
new file mode 100644
index 000000000..a8f744c76
--- /dev/null
+++ b/packages/core/src/repowise/core/analysis/health/crap.py
@@ -0,0 +1,111 @@
+"""Per-function coverage and the CRAP score, as pure functions.
+
+CRAP (Change Risk Anti-Patterns) is ``CC² × (1 − cov)³ + CC``: cyclomatic
+complexity weighted by how little of the function its tests run. At full
+coverage it is just ``CC``; untested, a ``CC`` of 5 already scores 30.
+
+Coverage is *measured* when a coverage report's line sets say which of the
+function's executable lines ran. Without that, coverage is a *tier*, never a
+number: ``direct`` (a test calls the function), ``reached`` (tests reach it or
+its file further out) or ``none``. A tier stands in for a coverage fraction
+only inside :func:`function_crap`, to rank estimates against each other, and
+never leaves this module as a percentage.
+"""
+
+from __future__ import annotations
+
+from bisect import bisect_left, bisect_right
+from collections.abc import Collection, Sequence
+from dataclasses import dataclass
+from typing import Literal
+
+#: The CRAP at which a function is worth a finding: an untested ``CC`` of 5.
+CRAP_THRESHOLD: float = 30.0
+
+CoverageBasis = Literal["measured", "estimated"]
+CoverageTier = Literal["direct", "reached", "none"]
+
+# Stand-ins for a tier, for ranking estimates only. A direct test runs most of
+# what it calls; reach further out runs some of it. Ceiling: fixed guesses, not
+# fitted; a corpus with per-function coverage could fit them.
+_TIER_FRACTION: dict[CoverageTier, float] = {"direct": 0.85, "reached": 0.4, "none": 0.0}
+
+
+@dataclass(frozen=True, slots=True)
+class FunctionCrap:
+ """One function's CRAP and what its coverage rests on.
+
+ ``coverage_pct`` is set only when measured, ``tier`` only when estimated.
+ """
+
+ crap: float
+ basis: CoverageBasis
+ tier: CoverageTier | None = None
+ coverage_pct: float | None = None
+
+
+def crap_score(ccn: int, coverage_fraction: float) -> float:
+ """``CC² × (1 − cov)³ + CC``, with *coverage_fraction* clamped to [0, 1]."""
+ uncovered = 1.0 - min(max(coverage_fraction, 0.0), 1.0)
+ return ccn * ccn * uncovered**3 + ccn
+
+
+def function_coverage(
+ spans: Sequence[tuple[int, int]],
+ covered_lines: Collection[int],
+ coverable_lines: Collection[int] | None = None,
+) -> list[float | None]:
+ """Each span's measured coverage fraction, ``None`` where the lines cannot say.
+
+ A line belongs to the innermost span holding it, so a nested function's
+ lines count for it and not for the function around it. The fraction is
+ covered over executable lines the span owns, so without *coverable_lines*
+ nothing is measured: a report that names only hit lines is silent, not
+ zero, about a function none of them fall in.
+ """
+ coverable = sorted(set(coverable_lines or ()))
+ if not coverable:
+ return [None] * len(spans)
+ covered = set(covered_lines)
+ owner: dict[int, int] = {}
+ # Outer spans first, so an inner span repaints the lines it holds.
+ for i in sorted(range(len(spans)), key=lambda i: (spans[i][0], -spans[i][1])):
+ start, end = spans[i]
+ for line in coverable[bisect_left(coverable, start) : bisect_right(coverable, end)]:
+ owner[line] = i
+ owned_covered = [0] * len(spans)
+ owned_coverable = [0] * len(spans)
+ for line, i in owner.items():
+ owned_coverable[i] += 1
+ owned_covered[i] += line in covered
+ return [
+ owned_covered[i] / owned_coverable[i] if owned_coverable[i] else None
+ for i in range(len(spans))
+ ]
+
+
+def coverage_tier(test_hops: int | None, file_reached: bool) -> CoverageTier:
+ """The tier for a function no measurement covers.
+
+ *test_hops* is the call distance to the nearest test that reaches the
+ function, ``None`` when none is known; *file_reached* says tests reach or
+ pair with its file.
+ """
+ if test_hops == 1:
+ return "direct"
+ if test_hops is not None or file_reached:
+ return "reached"
+ return "none"
+
+
+def function_crap(ccn: int, measured: float | None, tier: CoverageTier) -> FunctionCrap:
+ """The function's CRAP: measured when a fraction is given, else its tier's estimate.
+
+ A function the measurement says nothing about keeps its estimate, so a
+ report that misses it never scores it lower than no report would.
+ """
+ if measured is not None:
+ return FunctionCrap(
+ crap_score(ccn, measured), "measured", coverage_pct=round(measured * 100.0, 1)
+ )
+ return FunctionCrap(crap_score(ccn, _TIER_FRACTION[tier]), "estimated", tier=tier)
diff --git a/packages/core/src/repowise/core/analysis/health/engine.py b/packages/core/src/repowise/core/analysis/health/engine.py
index b86b67540..fea963a6a 100644
--- a/packages/core/src/repowise/core/analysis/health/engine.py
+++ b/packages/core/src/repowise/core/analysis/health/engine.py
@@ -22,7 +22,7 @@ import functools
import os
from datetime import UTC, datetime
from pathlib import Path, PurePosixPath
-from typing import Any
+from typing import TYPE_CHECKING, Any
import structlog
@@ -77,6 +77,9 @@ from .scoring import compute_kpis
from .source_reader import SourceReader, disk_source_reader
from .walk_cache import HealthWalkCache
+if TYPE_CHECKING:
+ from ..function_test_map import FunctionTests
+
log = structlog.get_logger(__name__)
# Bump when a change to this analyzer makes already-persisted health rows wrong
@@ -910,8 +913,13 @@ class HealthAnalyzer:
# per-file object, so no file is parsed twice for dataflow.
dataflow_cache = FileDataflowCache(self.read_source)
self.perf_stage.run(walked, dataflow_cache, timings)
+ # Before the evaluation: untested_complexity reads each function's nearest test.
+ with timed(timings, "analysis.health.function_tests"):
+ function_tests = self.test_index.function_tests()
with timed(timings, "analysis.health.repo_stats"):
- evaluator = self._file_evaluator(run, dup_report, fn_mod_p80, dataflow_cache)
+ evaluator = self._file_evaluator(
+ run, dup_report, fn_mod_p80, dataflow_cache, function_tests
+ )
with timed(timings, "analysis.health.evaluate"):
metrics, findings, suggestions = self._evaluate_all(evaluator, walked, on_step)
# KPIs are repo-wide; on an incremental run they would be biased
@@ -921,8 +929,6 @@ class HealthAnalyzer:
with timed(timings, "analysis.health.finalize"):
execution_roles = self._mark_perf_entry_reachability(findings)
suggestions = self._with_performance_plans(run, findings, suggestions)
- with timed(timings, "analysis.health.function_tests"):
- function_tests = self.test_index.function_tests()
return HealthReport(
repo_id="",
analyzed_at=datetime.now(UTC),
@@ -947,6 +953,7 @@ class HealthAnalyzer:
dup_report: DuplicationReport,
fn_mod_p80: int | None,
dataflow_cache: FileDataflowCache,
+ function_tests: FunctionTests | None = None,
) -> FileEvaluator:
"""The repo-wide inputs every file's evaluation reads, built once per pass."""
analyzed_paths = {pf.file_info.path for pf in self.parsed_files}
@@ -964,6 +971,7 @@ class HealthAnalyzer:
file_scc_index=build_file_scc_index(self.graph),
methods_by_file=build_methods_by_file(self.graph),
dataflow_cache=dataflow_cache,
+ function_tests=function_tests,
)
def _evaluate_all(
diff --git a/packages/core/src/repowise/core/analysis/health/file_evaluator.py b/packages/core/src/repowise/core/analysis/health/file_evaluator.py
index 28e7466a4..f7ee7ca69 100644
--- a/packages/core/src/repowise/core/analysis/health/file_evaluator.py
+++ b/packages/core/src/repowise/core/analysis/health/file_evaluator.py
@@ -27,6 +27,7 @@ from .scoring import attach_impacts, file_score_fields, remap_severities, score_
from .source_reader import SourceReader
if TYPE_CHECKING:
+ from ..function_test_map import FunctionTests
from .engine import HealthAnalyzer
#: Function facts a finding inside the function carries in its details.
@@ -221,6 +222,7 @@ class FileEvaluator:
file_scc_index: dict[str, tuple[str, ...]] | None = None
methods_by_file: dict[str, tuple[str, ...]] | None = None
dataflow_cache: FileDataflowCache | None = None
+ function_tests: FunctionTests | None = None
def evaluate(
self, pf: Any, fcx: FileComplexity
@@ -287,6 +289,7 @@ class FileEvaluator:
branch_coverage_pct=cov.get("branch_coverage_pct") if cov else None,
covered_lines=set(cov.get("covered_lines") or ()) if cov else set(),
total_coverable_lines=int(cov.get("total_coverable_lines", 0)) if cov else 0,
+ coverable_lines=set(cov.get("coverable_lines") or ()) if cov else set(),
reexport_only=bool(cov)
and is_reexport_only(pf, bool(fcx.functions), analyzer.read_source),
clones=list(clones),
@@ -300,8 +303,25 @@ class FileEvaluator:
perf_hits=fcx.perf_hits,
io_boundary_names=set(fcx.io_boundary_names),
cross_file_oracle_lines=frozenset(getattr(fcx, "cross_file_oracles", ())),
+ function_test_hops=self._function_test_hops(pf, fcx),
)
+ def _function_test_hops(self, pf: Any, fcx: FileComplexity) -> dict[int, int]:
+ """Each function's start line to the hops of the nearest test that reaches it."""
+ if not self.function_tests or pf.file_info.is_test:
+ return {}
+ index = self.analyzer._execution_graph()
+ if index is None:
+ return {}
+ path = pf.file_info.path
+ out: dict[int, int] = {}
+ for fc in fcx.functions:
+ symbol = index.resolve_function(path, fc.start_line, func_end=fc.end_line)
+ tests = self.function_tests.get(symbol) if symbol is not None else None
+ if tests:
+ out[fc.start_line] = tests[0].hops
+ return out
+
def _findings(
self, ctx: FileContext, fcx: FileComplexity
) -> tuple[list[HealthFindingData], dict[str, float | None]]:
diff --git a/packages/core/src/repowise/core/analysis/health/scoring.py b/packages/core/src/repowise/core/analysis/health/scoring.py
index 62ec555d9..ef1cbb5d8 100644
--- a/packages/core/src/repowise/core/analysis/health/scoring.py
+++ b/packages/core/src/repowise/core/analysis/health/scoring.py
@@ -199,6 +199,8 @@ _BIOMARKER_CATEGORY: dict[str, str] = {
"dry_violation": "duplication",
"untested_hotspot": "test_coverage",
"coverage_gap": "test_coverage",
+ # Advisory (deducts nothing); filed with the coverage markers it explains.
+ "untested_complexity": "test_coverage",
"coverage_gradient": "test_coverage_gradient",
"developer_congestion": "organizational",
"knowledge_loss": "organizational",
@@ -324,6 +326,10 @@ _BIOMARKER_DIMENSIONS: dict[str, set[str]] = {
# Fires only beside complex_method and large_method on the same function, so
# scoring it charged that function twice; dropping it moved no defect AUC.
"brain_method": {ADVISORY_DIMENSION},
+ # Its two inputs already deduct: complexity through complex_method, missing
+ # coverage through coverage_gap and coverage_gradient. Uncalibrated; it ranks
+ # which complex functions most need tests rather than moving the score.
+ "untested_complexity": {ADVISORY_DIMENSION},
}
# Maintainability per-biomarker weight multipliers. Expert-set by definition -
@@ -545,7 +551,13 @@ _PERFORMANCE_HOME: frozenset[str] = frozenset(
# The display half of the pairing above; ``test_advisory_dimension.py`` locks
# the two together for every registered biomarker.
_ADVISORY_HOME: frozenset[str] = frozenset(
- {"assertion_free_test", "mock_saturated_test", "hidden_coupling", "brain_method"}
+ {
+ "assertion_free_test",
+ "mock_saturated_test",
+ "hidden_coupling",
+ "brain_method",
+ "untested_complexity",
+ }
)
diff --git a/packages/core/src/repowise/core/analysis/health/suggestions.py b/packages/core/src/repowise/core/analysis/health/suggestions.py
index 8ff85cd8d..3b695d299 100644
--- a/packages/core/src/repowise/core/analysis/health/suggestions.py
+++ b/packages/core/src/repowise/core/analysis/health/suggestions.py
@@ -76,6 +76,11 @@ _TEMPLATES: dict[str, str] = {
"tests for the current behavior first, then refactor with "
"confidence."
),
+ "untested_complexity": (
+ "Test this function's branches first: it is complex and little of it "
+ "runs under test. When its complexity is 30 or more, split it instead, "
+ "since no amount of coverage brings its score under the bar."
+ ),
"coverage_gap": (
"Cover the uncovered branches. Start with the highest-impact "
"uncovered code paths (errors, edge cases, security-sensitive "
diff --git a/packages/core/src/repowise/core/persistence/crud/analysis/coverage.py b/packages/core/src/repowise/core/persistence/crud/analysis/coverage.py
index 1225cd160..dddc5b463 100644
--- a/packages/core/src/repowise/core/persistence/crud/analysis/coverage.py
+++ b/packages/core/src/repowise/core/persistence/crud/analysis/coverage.py
@@ -457,10 +457,13 @@ async def load_coverage_map(session: AsyncSession, repository_id: str) -> dict[s
"""Stored coverage in the shape ``HealthAnalyzer`` takes as ``coverage_map``."""
from repowise.core.analysis.health.coverage.model import coverage_map_entry
- # Health scoring never reads the executable-line set, so its blob is not
- # loaded (it is at least as large as the covered set).
+ # Both line sets: per-function coverage divides covered by executable lines.
result = await session.execute(
- select(*_COVERAGE_SCALAR_COLUMNS, CoverageFile.covered_lines_json).where(
+ select(
+ *_COVERAGE_SCALAR_COLUMNS,
+ CoverageFile.covered_lines_json,
+ CoverageFile.coverable_lines_json,
+ ).where(
CoverageFile.repository_id == repository_id
)
)
diff --git a/packages/ui/src/health/generated/biomarker-labels.ts b/packages/ui/src/health/generated/biomarker-labels.ts
index 5cef4b1d0..6db614e0e 100644
--- a/packages/ui/src/health/generated/biomarker-labels.ts
+++ b/packages/ui/src/health/generated/biomarker-labels.ts
@@ -13,6 +13,7 @@ export const BIOMARKER_LABELS = {
dry_violation: "DRY violation",
untested_hotspot: "Untested hotspot",
coverage_gap: "Coverage gap",
+ untested_complexity: "Untested complexity",
coverage_gradient: "Coverage gradient",
developer_congestion: "Many authors",
knowledge_loss: "Fading ownership",
diff --git a/tests/unit/health/golden/health_engine.json b/tests/unit/health/golden/health_engine.json
index b17269793..2fcd804a0 100644
--- a/tests/unit/health/golden/health_engine.json
+++ b/tests/unit/health/golden/health_engine.json
@@ -21,7 +21,108 @@
"code_origin": "production"
}
],
- "findings": [],
+ "findings": [
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "inventory.go",
+ "function_name": "FastestSupplier",
+ "line_start": 155,
+ "line_end": 166,
+ "details": {
+ "crap": 42.0,
+ "ccn": 6,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 155
+ },
+ "health_impact": 0.0,
+ "reason": "FastestSupplier has CRAP 42 (complexity 6, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_9c4e543562fe5f8b76ad"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "inventory.go",
+ "function_name": "AddLine",
+ "line_start": 224,
+ "line_end": 239,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 224
+ },
+ "health_impact": 0.0,
+ "reason": "AddLine has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_03e106976978913f3b80"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "inventory.go",
+ "function_name": "OrdersBySupplier",
+ "line_start": 271,
+ "line_end": 284,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 271
+ },
+ "health_impact": 0.0,
+ "reason": "OrdersBySupplier has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_74751d6b8941656b8a14"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "inventory.go",
+ "function_name": "OpenOrders",
+ "line_start": 286,
+ "line_end": 298,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 286
+ },
+ "health_impact": 0.0,
+ "reason": "OpenOrders has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_d596f31c5cf5b49adb34"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "inventory.go",
+ "function_name": "ReceiveOrder",
+ "line_start": 332,
+ "line_end": 351,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 332
+ },
+ "health_impact": 0.0,
+ "reason": "ReceiveOrder has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_fd719cff20def72136b2"
+ }
+ ],
"kpis": {
"hotspot_health": null,
"average_health": 10.0,
@@ -208,6 +309,26 @@
"dimension": "maintainability",
"id": "finding_adecdf1cea8a1aad2796"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "account.ts",
+ "function_name": "parseAccount",
+ "line_start": 15,
+ "line_end": 56,
+ "details": {
+ "crap": 306.0,
+ "ccn": 17,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 15
+ },
+ "health_impact": 0.0,
+ "reason": "parseAccount has CRAP 306 (complexity 17, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_01e0fea6a9a9584edcb7"
+ },
{
"biomarker_type": "complex_method",
"severity": "high",
@@ -249,6 +370,26 @@
"reason": "97% of file duplicated in other files; worst clone shares 68 lines with account.ts",
"dimension": "maintainability",
"id": "finding_27bf987f937f7819f307"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "workspace.ts",
+ "function_name": "parseWorkspace",
+ "line_start": 15,
+ "line_end": 56,
+ "details": {
+ "crap": 306.0,
+ "ccn": 17,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 15
+ },
+ "health_impact": 0.0,
+ "reason": "parseWorkspace has CRAP 306 (complexity 17, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_73748342cd33391dda21"
}
],
"kpis": {
@@ -458,6 +599,186 @@
"reason": "close_project has cyclomatic complexity 10",
"dimension": "defect",
"id": "finding_ebd7768c22e919caee2c"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "handlers.py",
+ "function_name": "read_account",
+ "line_start": 22,
+ "line_end": 48,
+ "details": {
+ "crap": 156.0,
+ "ccn": 12,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 22
+ },
+ "health_impact": 0.0,
+ "reason": "read_account has CRAP 156 (complexity 12, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_be3bc1e43f396ec4b1d2"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "handlers.py",
+ "function_name": "close_account",
+ "line_start": 52,
+ "line_end": 71,
+ "details": {
+ "crap": 110.0,
+ "ccn": 10,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 52
+ },
+ "health_impact": 0.0,
+ "reason": "close_account has CRAP 110 (complexity 10, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_8d5ebbeab16804227744"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "handlers.py",
+ "function_name": "list_accounts",
+ "line_start": 75,
+ "line_end": 83,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 75
+ },
+ "health_impact": 0.0,
+ "reason": "list_accounts has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_01fbce0dcb4b8c1cbbcf"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "handlers.py",
+ "function_name": "read_workspace",
+ "line_start": 86,
+ "line_end": 112,
+ "details": {
+ "crap": 156.0,
+ "ccn": 12,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 86
+ },
+ "health_impact": 0.0,
+ "reason": "read_workspace has CRAP 156 (complexity 12, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_c3ce87446b4e7949dc32"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "handlers.py",
+ "function_name": "close_workspace",
+ "line_start": 116,
+ "line_end": 135,
+ "details": {
+ "crap": 110.0,
+ "ccn": 10,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 116
+ },
+ "health_impact": 0.0,
+ "reason": "close_workspace has CRAP 110 (complexity 10, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_d01c9e91d2a81a69d705"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "handlers.py",
+ "function_name": "list_workspaces",
+ "line_start": 139,
+ "line_end": 147,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 139
+ },
+ "health_impact": 0.0,
+ "reason": "list_workspaces has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_ea0dc36989d7db2e3cd9"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "handlers.py",
+ "function_name": "read_project",
+ "line_start": 150,
+ "line_end": 176,
+ "details": {
+ "crap": 156.0,
+ "ccn": 12,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 150
+ },
+ "health_impact": 0.0,
+ "reason": "read_project has CRAP 156 (complexity 12, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_dc33685f497d775411c5"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "handlers.py",
+ "function_name": "close_project",
+ "line_start": 180,
+ "line_end": 199,
+ "details": {
+ "crap": 110.0,
+ "ccn": 10,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 180
+ },
+ "health_impact": 0.0,
+ "reason": "close_project has CRAP 110 (complexity 10, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_47eeb076a35072b87323"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "handlers.py",
+ "function_name": "list_projects",
+ "line_start": 203,
+ "line_end": 211,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 203
+ },
+ "health_impact": 0.0,
+ "reason": "list_projects has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_1941c4a02c0d4659337a"
}
],
"kpis": {
@@ -1840,6 +2161,26 @@
"dimension": "defect",
"id": "finding_7336de57febe95c93630"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "cpp/nested.cpp",
+ "function_name": "deeplyNested",
+ "line_start": 3,
+ "line_end": 14,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 3
+ },
+ "health_impact": 0.0,
+ "reason": "deeplyNested has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_294c508a3bdf5636dbc5"
+ },
{
"biomarker_type": "io_in_loop",
"severity": "medium",
@@ -2040,6 +2381,26 @@
"dimension": "defect",
"id": "finding_525e8162089608e8a869"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "csharp/nested.cs",
+ "function_name": "DeeplyNested",
+ "line_start": 5,
+ "line_end": 21,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 5
+ },
+ "health_impact": 0.0,
+ "reason": "DeeplyNested has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_06ba5b0fe6a38fa75b04"
+ },
{
"biomarker_type": "nested_complexity",
"severity": "medium",
@@ -2086,6 +2447,46 @@
"dimension": "defect",
"id": "finding_75e1face476206b793af"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "dart/nested.dart",
+ "function_name": "deeplyNested",
+ "line_start": 3,
+ "line_end": 14,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 3
+ },
+ "health_impact": 0.0,
+ "reason": "deeplyNested has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_3b2e6e678827a0c95db8"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "dart/nested.dart",
+ "function_name": "manyBranches",
+ "line_start": 20,
+ "line_end": 28,
+ "details": {
+ "crap": 90.0,
+ "ccn": 9,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 20
+ },
+ "health_impact": 0.0,
+ "reason": "manyBranches has CRAP 90 (complexity 9, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_c1ac480b4aeb3197f16d"
+ },
{
"biomarker_type": "io_in_loop",
"severity": "medium",
@@ -2194,6 +2595,46 @@
"dimension": "performance",
"id": "finding_fc2bd6cbf299ac72583b"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "go/conditionals.go",
+ "function_name": "ThreeOps",
+ "line_start": 3,
+ "line_end": 8,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 3
+ },
+ "health_impact": 0.0,
+ "reason": "ThreeOps has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_814731f9fbc11f91edc5"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "go/conditionals.go",
+ "function_name": "SixOps",
+ "line_start": 10,
+ "line_end": 15,
+ "details": {
+ "crap": 72.0,
+ "ccn": 8,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 10
+ },
+ "health_impact": 0.0,
+ "reason": "SixOps has CRAP 72 (complexity 8, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_c1cb731e126a1224c410"
+ },
{
"biomarker_type": "complex_conditional",
"severity": "low",
@@ -2255,6 +2696,26 @@
"dimension": "defect",
"id": "finding_8a94b5551a568cc7522f"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "go/nested.go",
+ "function_name": "DeeplyNested",
+ "line_start": 3,
+ "line_end": 17,
+ "details": {
+ "crap": 42.0,
+ "ccn": 6,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 3
+ },
+ "health_impact": 0.0,
+ "reason": "DeeplyNested has CRAP 42 (complexity 6, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_d271936fd68e02aa1a7f"
+ },
{
"biomarker_type": "error_handling",
"severity": "low",
@@ -2425,6 +2886,46 @@
"dimension": "performance",
"id": "finding_7f34c7947a7498cc922c"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "java/Conditionals.java",
+ "function_name": "threeOps",
+ "line_start": 2,
+ "line_end": 7,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 2
+ },
+ "health_impact": 0.0,
+ "reason": "threeOps has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_5cad121e3eec66668619"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "java/Conditionals.java",
+ "function_name": "sixOps",
+ "line_start": 9,
+ "line_end": 14,
+ "details": {
+ "crap": 72.0,
+ "ccn": 8,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 9
+ },
+ "health_impact": 0.0,
+ "reason": "sixOps has CRAP 72 (complexity 8, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_fd14e71841abee247de5"
+ },
{
"biomarker_type": "complex_conditional",
"severity": "low",
@@ -2486,6 +2987,26 @@
"dimension": "defect",
"id": "finding_716ef8994749727b5d74"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "java/Nested.java",
+ "function_name": "deeplyNested",
+ "line_start": 2,
+ "line_end": 19,
+ "details": {
+ "crap": 56.0,
+ "ccn": 7,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 2
+ },
+ "health_impact": 0.0,
+ "reason": "deeplyNested has CRAP 56 (complexity 7, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_37724bd1b3882e3b1429"
+ },
{
"biomarker_type": "error_handling",
"severity": "low",
@@ -2659,6 +3180,26 @@
"dimension": "defect",
"id": "finding_bd08c69b932b606b18c9"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "javascript/nested.js",
+ "function_name": "deeplyNested",
+ "line_start": 1,
+ "line_end": 17,
+ "details": {
+ "crap": 56.0,
+ "ccn": 7,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 1
+ },
+ "health_impact": 0.0,
+ "reason": "deeplyNested has CRAP 56 (complexity 7, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_f4d48fd3c571c65c8066"
+ },
{
"biomarker_type": "error_handling",
"severity": "low",
@@ -2699,6 +3240,26 @@
"dimension": "defect",
"id": "finding_341db9359cf919b9c51c"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "kotlin/nested.kt",
+ "function_name": "deeplyNested",
+ "line_start": 3,
+ "line_end": 14,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 3
+ },
+ "health_impact": 0.0,
+ "reason": "deeplyNested has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_763d93b2e5a15a2123fe"
+ },
{
"biomarker_type": "complex_method",
"severity": "medium",
@@ -2722,6 +3283,26 @@
"dimension": "defect",
"id": "finding_cdb1bfd5e7f5961c0f48"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "pascal/complex.pas",
+ "function_name": "ManyBranches",
+ "line_start": 7,
+ "line_end": 46,
+ "details": {
+ "crap": 182.0,
+ "ccn": 13,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 7
+ },
+ "health_impact": 0.0,
+ "reason": "ManyBranches has CRAP 182 (complexity 13, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_7fa470e6114dc37b6fd9"
+ },
{
"biomarker_type": "nested_complexity",
"severity": "high",
@@ -2745,6 +3326,26 @@
"dimension": "defect",
"id": "finding_472f3545d0b4e4e51dcb"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "pascal/nested.pas",
+ "function_name": "DeeplyNested",
+ "line_start": 7,
+ "line_end": 30,
+ "details": {
+ "crap": 42.0,
+ "ccn": 6,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 7
+ },
+ "health_impact": 0.0,
+ "reason": "DeeplyNested has CRAP 42 (complexity 6, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_d69da900f78a85b1c0f8"
+ },
{
"biomarker_type": "nested_complexity",
"severity": "medium",
@@ -2768,6 +3369,26 @@
"dimension": "defect",
"id": "finding_08fb66e3bd4471dcc116"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "php/nested.php",
+ "function_name": "deeply_nested",
+ "line_start": 4,
+ "line_end": 15,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 4
+ },
+ "health_impact": 0.0,
+ "reason": "deeply_nested has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_6a2d7046d153f5e28f70"
+ },
{
"biomarker_type": "low_cohesion",
"severity": "medium",
@@ -2810,6 +3431,66 @@
"dimension": "defect",
"id": "finding_0218dfee9ddbbc3acb0c"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "python/complex.py",
+ "function_name": "many_branches",
+ "line_start": 1,
+ "line_end": 21,
+ "details": {
+ "crap": 240.0,
+ "ccn": 15,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 1
+ },
+ "health_impact": 0.0,
+ "reason": "many_branches has CRAP 240 (complexity 15, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_878a89457f1905e001a4"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "python/conditionals.py",
+ "function_name": "three_ops",
+ "line_start": 1,
+ "line_end": 4,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 1
+ },
+ "health_impact": 0.0,
+ "reason": "three_ops has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_e51ed3bb71580fb53c52"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "python/conditionals.py",
+ "function_name": "six_ops",
+ "line_start": 7,
+ "line_end": 10,
+ "details": {
+ "crap": 72.0,
+ "ccn": 8,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 7
+ },
+ "health_impact": 0.0,
+ "reason": "six_ops has CRAP 72 (complexity 8, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_9ce0eaced1fca0186c01"
+ },
{
"biomarker_type": "complex_conditional",
"severity": "low",
@@ -2871,6 +3552,26 @@
"dimension": "defect",
"id": "finding_d4ee38f48a43bc6c92fd"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "python/nested.py",
+ "function_name": "deeply_nested",
+ "line_start": 1,
+ "line_end": 12,
+ "details": {
+ "crap": 56.0,
+ "ccn": 7,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 1
+ },
+ "health_impact": 0.0,
+ "reason": "deeply_nested has CRAP 56 (complexity 7, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_b229a93c6dc594cdc15f"
+ },
{
"biomarker_type": "error_handling",
"severity": "low",
@@ -3079,6 +3780,46 @@
"dimension": "defect",
"id": "finding_980163708d497ecefb31"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "ruby/nested.rb",
+ "function_name": "deeply_nested",
+ "line_start": 3,
+ "line_end": 14,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 3
+ },
+ "health_impact": 0.0,
+ "reason": "deeply_nested has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_75bf41261c0bcdf5e53c"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "ruby/nested.rb",
+ "function_name": "many_branches",
+ "line_start": 16,
+ "line_end": 27,
+ "details": {
+ "crap": 56.0,
+ "ccn": 7,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 16
+ },
+ "health_impact": 0.0,
+ "reason": "many_branches has CRAP 56 (complexity 7, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_77744cd877e0d96bea97"
+ },
{
"biomarker_type": "io_in_loop",
"severity": "medium",
@@ -3386,6 +4127,46 @@
"dimension": "performance",
"id": "finding_8ef9939b9fdcbcf63e88"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "rust/conditionals.rs",
+ "function_name": "three_ops",
+ "line_start": 1,
+ "line_end": 6,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 1
+ },
+ "health_impact": 0.0,
+ "reason": "three_ops has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_a42703ee8e4769a7c306"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "rust/conditionals.rs",
+ "function_name": "six_ops",
+ "line_start": 8,
+ "line_end": 13,
+ "details": {
+ "crap": 72.0,
+ "ccn": 8,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 8
+ },
+ "health_impact": 0.0,
+ "reason": "six_ops has CRAP 72 (complexity 8, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_7e8892978e25daab749c"
+ },
{
"biomarker_type": "complex_conditional",
"severity": "low",
@@ -3447,6 +4228,26 @@
"dimension": "defect",
"id": "finding_51c3d3fb3a7baa49f5d1"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "rust/nested.rs",
+ "function_name": "deeply_nested",
+ "line_start": 1,
+ "line_end": 16,
+ "details": {
+ "crap": 42.0,
+ "ccn": 6,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 1
+ },
+ "health_impact": 0.0,
+ "reason": "deeply_nested has CRAP 42 (complexity 6, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_274f31bce9e3a7e76826"
+ },
{
"biomarker_type": "io_in_loop",
"severity": "medium",
@@ -3664,6 +4465,46 @@
"dimension": "defect",
"id": "finding_35278d63e4c3bf59be37"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "scala/nested.scala",
+ "function_name": "deeplyNested",
+ "line_start": 4,
+ "line_end": 18,
+ "details": {
+ "crap": 42.0,
+ "ccn": 6,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 4
+ },
+ "health_impact": 0.0,
+ "reason": "deeplyNested has CRAP 42 (complexity 6, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_bef116cdaae8db9288a4"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "scala/nested.scala",
+ "function_name": "manyBranches",
+ "line_start": 20,
+ "line_end": 28,
+ "details": {
+ "crap": 90.0,
+ "ccn": 9,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 20
+ },
+ "health_impact": 0.0,
+ "reason": "manyBranches has CRAP 90 (complexity 9, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_5bf22a92bcba1473b280"
+ },
{
"biomarker_type": "io_in_loop",
"severity": "medium",
@@ -3851,6 +4692,26 @@
"dimension": "defect",
"id": "finding_d2fe951005c971f897c1"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "shell/control_flow.sh",
+ "function_name": "process",
+ "line_start": 5,
+ "line_end": 36,
+ "details": {
+ "crap": 110.0,
+ "ccn": 10,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 5
+ },
+ "health_impact": 0.0,
+ "reason": "process has CRAP 110 (complexity 10, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_45212a20ebb63db6f7dc"
+ },
{
"biomarker_type": "nested_complexity",
"severity": "medium",
@@ -3874,6 +4735,26 @@
"dimension": "defect",
"id": "finding_d407fd3ab687e2789f32"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "swift/nested.swift",
+ "function_name": "deeplyNested",
+ "line_start": 3,
+ "line_end": 14,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 3
+ },
+ "health_impact": 0.0,
+ "reason": "deeplyNested has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_8bf514f1b02c06aca9a2"
+ },
{
"biomarker_type": "low_cohesion",
"severity": "medium",
@@ -3893,6 +4774,46 @@
"dimension": "maintainability",
"id": "finding_71eaf8ee511ffe4dce0d"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "typescript/conditionals.ts",
+ "function_name": "threeOps",
+ "line_start": 1,
+ "line_end": 6,
+ "details": {
+ "crap": 30.0,
+ "ccn": 5,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 1
+ },
+ "health_impact": 0.0,
+ "reason": "threeOps has CRAP 30 (complexity 5, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_d6eb483a3c2792253001"
+ },
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "typescript/conditionals.ts",
+ "function_name": "sixOps",
+ "line_start": 8,
+ "line_end": 21,
+ "details": {
+ "crap": 72.0,
+ "ccn": 8,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 8
+ },
+ "health_impact": 0.0,
+ "reason": "sixOps has CRAP 72 (complexity 8, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_97168cde0d08fc10589a"
+ },
{
"biomarker_type": "complex_conditional",
"severity": "low",
@@ -3954,6 +4875,26 @@
"dimension": "defect",
"id": "finding_28aa3ceec6692a33ea1e"
},
+ {
+ "biomarker_type": "untested_complexity",
+ "severity": "medium",
+ "file_path": "typescript/nested.ts",
+ "function_name": "deeplyNested",
+ "line_start": 1,
+ "line_end": 19,
+ "details": {
+ "crap": 56.0,
+ "ccn": 7,
+ "coverage_basis": "estimated",
+ "action": "add_tests",
+ "coverage_tier": "none",
+ "symbol_line": 1
+ },
+ "health_impact": 0.0,
+ "reason": "deeplyNested has CRAP 56 (complexity 7, estimated, no test found reaching it)",
+ "dimension": "advisory",
+ "id": "finding_b8dce4aaa790eae85100"
+ },
{
"biomarker_type": "error_handling",
"severity": "low",
diff --git a/tests/unit/health/test_scoring_snapshot.py b/tests/unit/health/test_scoring_snapshot.py
index 694aed6a1..412a57957 100644
--- a/tests/unit/health/test_scoring_snapshot.py
+++ b/tests/unit/health/test_scoring_snapshot.py
@@ -97,6 +97,7 @@ _EXPECTED_BIOMARKER_CATEGORY = {
"dry_violation": "duplication",
"untested_hotspot": "test_coverage",
"coverage_gap": "test_coverage",
+ "untested_complexity": "test_coverage",
"coverage_gradient": "test_coverage_gradient",
"developer_congestion": "organizational",
"knowledge_loss": "organizational",
diff --git a/tests/unit/health/test_untested_complexity.py b/tests/unit/health/test_untested_complexity.py
new file mode 100644
index 000000000..b573ac296
--- /dev/null
+++ b/tests/unit/health/test_untested_complexity.py
@@ -0,0 +1,328 @@
+"""Per-function coverage, the CRAP score and the ``untested_complexity`` finding."""
+
+from __future__ import annotations
+
+import networkx as nx
+import pytest
+
+from repowise.core.analysis.health import HealthAnalyzer
+from repowise.core.analysis.health.biomarkers import FileContext
+from repowise.core.analysis.health.biomarkers.untested_complexity import BIOMARKER
+from repowise.core.analysis.health.complexity.models import FunctionComplexity
+from repowise.core.analysis.health.crap import (
+ CRAP_THRESHOLD,
+ coverage_tier,
+ crap_score,
+ function_coverage,
+ function_crap,
+)
+from repowise.core.ingestion.parser import parse_file
+from repowise.core.ingestion.traverser import FileTraverser
+
+# --------------------------------------------------------------------------
+# The formula
+# --------------------------------------------------------------------------
+
+
+ ("ccn", "cov", "expected"),
+ [
+ (5, 0.0, 30.0), # the threshold: an untested CC of 5
+ (10, 1.0, 10.0), # full coverage leaves CC
+ (10, 0.5, 22.5),
+ (1, 0.0, 2.0),
+ (30, 1.0, 30.0), # cannot get under the bar by testing
+ (4, -0.5, 20.0), # clamped to [0, 1]
+ (4, 1.5, 4.0),
+ ],
+)
+def test_crap_score(ccn: int, cov: float, expected: float) -> None:
+ assert crap_score(ccn, cov) == pytest.approx(expected)
+
+
+def test_threshold_is_an_untested_cc_of_five() -> None:
+ assert crap_score(5, 0.0) == CRAP_THRESHOLD
+
+
+# --------------------------------------------------------------------------
+# Measured per-function coverage
+# --------------------------------------------------------------------------
+
+
+def test_span_edges_are_inclusive() -> None:
+ assert function_coverage([(3, 5)], {3, 5}, {2, 3, 4, 5, 6}) == [pytest.approx(2 / 3)]
+
+
+def test_a_nested_function_owns_its_own_lines() -> None:
+ outer, inner = (1, 10), (3, 5)
+ got = function_coverage([outer, inner], covered_lines={1, 2, 3}, coverable_lines={1, 2, 3, 4, 6, 7})
+ # outer owns 1, 2, 6, 7; inner owns 3, 4
+ assert got == [pytest.approx(0.5), pytest.approx(0.5)]
+
+
+def test_covered_lines_outside_the_executable_set_do_not_count() -> None:
+ assert function_coverage([(1, 4)], {1, 2, 3}, {1, 4}) == [pytest.approx(0.5)]
+
+
+def test_a_span_with_no_executable_line_is_unmeasured() -> None:
+ assert function_coverage([(20, 25)], {1}, {1, 2}) == [None]
+
+
+def test_without_executable_lines_nothing_is_measured() -> None:
+ assert function_coverage([(1, 5), (6, 9)], {2}, None) == [None, None]
+
+
+# --------------------------------------------------------------------------
+# Tiers and the estimate
+# --------------------------------------------------------------------------
+
+
+ ("hops", "reached", "tier"),
+ [(1, False, "direct"), (2, False, "reached"), (None, True, "reached"), (None, False, "none")],
+)
+def test_coverage_tier(hops: int | None, reached: bool, tier: str) -> None:
+ assert coverage_tier(hops, reached) == tier
+
+
+def test_an_estimate_carries_a_tier_and_never_a_percentage() -> None:
+ result = function_crap(8, None, "reached")
+ assert result.basis == "estimated"
+ assert result.tier == "reached"
+ assert result.coverage_pct is None
+
+
+def test_a_measurement_carries_a_percentage_and_no_tier() -> None:
+ result = function_crap(8, 0.25, "none")
+ assert (result.basis, result.tier, result.coverage_pct) == ("measured", None, 25.0)
+
+
[email protected](("hops", "reached"), [(None, False), (None, True), (2, False)])
+def test_a_function_the_report_misses_keeps_its_estimate(hops, reached) -> None:
+ """A report that says nothing about a function never scores it below no report."""
+ fn = _fn("f", 10, 30, 12)
+ alone = _ctx([fn], reached_by_tests=reached, function_test_hops={10: hops} if hops else {})
+ lines = set(range(1, 6))
+ reported = _ctx(
+ [fn],
+ reached_by_tests=reached,
+ function_test_hops={10: hops} if hops else {},
+ line_coverage_pct=100.0,
+ covered_lines=lines,
+ coverable_lines=lines,
+ total_coverable_lines=5,
+ )
+ assert _one(reported).details == _one(alone).details
+ assert _one(reported).details["coverage_basis"] == "estimated"
+
+
+# --------------------------------------------------------------------------
+# The biomarker
+# --------------------------------------------------------------------------
+
+
+def _fn(name: str, start: int, end: int, ccn: int) -> FunctionComplexity:
+ return FunctionComplexity(
+ name=name, start_line=start, end_line=end, ccn=ccn, max_nesting=1, cognitive=ccn, nloc=end - start
+ )
+
+
+def _ctx(functions, **kw) -> FileContext:
+ base = {
+ "file_path": "src/app.py",
+ "language": "python",
+ "nloc": 100,
+ "has_test_file": False,
+ "module": None,
+ "is_test": False,
+ "all_functions": tuple(functions),
+ }
+ base.update(kw)
+ return FileContext(**base)
+
+
+def _one(ctx: FileContext):
+ results = BIOMARKER.detect(ctx)
+ assert len(results) == 1, results
+ return results[0]
+
+
+def test_an_untested_cc_of_five_fires_estimated_and_medium() -> None:
+ r = _one(_ctx([_fn("f", 1, 20, 5)]))
+ assert r.severity.value == "medium"
+ assert r.details["coverage_basis"] == "estimated"
+ assert r.details["coverage_tier"] == "none"
+ assert "coverage_pct" not in r.details
+ assert "%" not in r.reason
+
+
+def test_below_the_bar_is_silent() -> None:
+ assert BIOMARKER.detect(_ctx([_fn("f", 1, 20, 4)])) == []
+
+
+def test_a_directly_tested_function_is_estimated_low() -> None:
+ ctx = _ctx([_fn("f", 1, 20, 10)], function_test_hops={1: 1})
+ assert BIOMARKER.detect(ctx) == []
+
+
+def test_the_estimate_caps_at_medium() -> None:
+ r = _one(_ctx([_fn("f", 1, 40, 20)])) # CRAP 420 estimated
+ assert r.severity.value == "medium"
+
+
+ ("ccn", "severity"),
+ [(5, "medium"), (7, "high"), (10, "critical")], # CRAP 30, 56, 110 at 0%
+)
+def test_measured_severity_bands(ccn: int, severity: str) -> None:
+ ctx = _ctx(
+ [_fn("f", 1, 20, ccn)],
+ line_coverage_pct=0.0,
+ covered_lines=set(),
+ coverable_lines=set(range(1, 21)),
+ total_coverable_lines=20,
+ )
+ r = _one(ctx)
+ assert r.severity.value == severity
+ assert r.details["coverage_basis"] == "measured"
+ assert r.details["coverage_pct"] == 0.0
+ assert "coverage_tier" not in r.details
+
+
+def test_measured_full_coverage_clears_a_moderate_function() -> None:
+ lines = set(range(1, 21))
+ ctx = _ctx(
+ [_fn("f", 1, 20, 10)],
+ line_coverage_pct=100.0,
+ covered_lines=lines,
+ coverable_lines=lines,
+ total_coverable_lines=20,
+ )
+ assert BIOMARKER.detect(ctx) == []
+
+
+def test_a_report_without_line_sets_falls_back_to_the_estimate() -> None:
+ """A pinned percentage with no lines says nothing about one function."""
+ ctx = _ctx([_fn("f", 1, 20, 6)], line_coverage_pct=80.0, total_coverable_lines=20)
+ assert _one(ctx).details["coverage_basis"] == "estimated"
+
+
+def test_a_file_the_report_ran_none_of_is_measured_at_zero() -> None:
+ ctx = _ctx([_fn("f", 1, 20, 7)], line_coverage_pct=0.0, total_coverable_lines=20)
+ r = _one(ctx)
+ assert (r.details["coverage_basis"], r.severity.value) == ("measured", "high")
+
+
+def test_a_hit_line_set_without_executable_lines_keeps_the_estimate() -> None:
+ """Only hit lines named: silent about the function, not zero."""
+ ctx = _ctx(
+ [_fn("f", 10, 30, 7)], line_coverage_pct=40.0, covered_lines={1, 2}, total_coverable_lines=5
+ )
+ assert _one(ctx).details["coverage_basis"] == "estimated"
+
+
+def test_a_paired_test_file_counts_as_reach() -> None:
+ r = _one(_ctx([_fn("f", 1, 20, 12)], has_test_file=True))
+ assert r.details["coverage_tier"] == "reached"
+
+
+def test_complexity_of_thirty_steers_to_refactoring() -> None:
+ lines = set(range(1, 61))
+ ctx = _ctx(
+ [_fn("f", 1, 60, 30)],
+ line_coverage_pct=100.0,
+ covered_lines=lines,
+ coverable_lines=lines,
+ total_coverable_lines=60,
+ )
+ r = _one(ctx)
+ assert r.details["action"] == "refactor"
+ assert "simplify" in r.reason
+ assert _one(_ctx([_fn("g", 1, 20, 6)])).details["action"] == "add_tests"
+
+
+def test_no_finding_on_test_files() -> None:
+ assert BIOMARKER.detect(_ctx([_fn("f", 1, 20, 12)], file_path="tests/test_app.py", is_test=True)) == []
+
+
+def test_the_stored_flag_decides_for_a_test_named_production_module() -> None:
+ ctx = _ctx([_fn("f", 1, 20, 12)], file_path="core/test_selection.py", is_test=False)
+ assert len(BIOMARKER.detect(ctx)) == 1
+
+
+# --------------------------------------------------------------------------
+# Engine wiring: the direct tier comes from the call graph
+# --------------------------------------------------------------------------
+
+# Complexity 12: only the direct tier clears it (reach alone estimates CRAP 43).
+_FLAGS = "abcdefghijk"
+_BRANCHY = (
+ f"def route({', '.join(_FLAGS)}):\n"
+ + "".join(f" if {flag}:\n return {i}\n" for i, flag in enumerate(_FLAGS, 1))
+ + " return 0\n"
+)
+
+
+def _tree(tmp_path):
+ (tmp_path / "src").mkdir(parents=True)
+ (tmp_path / "tests").mkdir()
+ (tmp_path / "src" / "router.py").write_text(_BRANCHY, encoding="utf-8")
+ (tmp_path / "tests" / "test_router.py").write_text(
+ "from src.router import route\n\n\ndef test_it():\n assert route(*[1] * 11) == 1\n",
+ encoding="utf-8",
+ )
+ return [parse_file(f, (tmp_path / f.path).read_bytes()) for f in FileTraverser(tmp_path).traverse()]
+
+
+def _graph(*, calls: bool, via_helper: bool = False) -> nx.DiGraph:
+ g = nx.DiGraph()
+ for path, name, start, end in (
+ ("tests/test_router.py", "test_it", 4, 5),
+ ("src/router.py", "route", 1, 24),
+ ("src/glue.py", "relay", 1, 2),
+ ):
+ sid = f"{path}::{name}"
+ g.add_node(sid, node_type="symbol", name=name, file_path=path, start_line=start, end_line=end)
+ g.add_edge(path, sid, edge_type="defines")
+ if via_helper:
+ g.add_edge("tests/test_router.py::test_it", "src/glue.py::relay", edge_type="calls")
+ g.add_edge("src/glue.py::relay", "src/router.py::route", edge_type="calls")
+ elif calls:
+ g.add_edge("tests/test_router.py::test_it", "src/router.py::route", edge_type="calls")
+ return g
+
+
+def _crap_findings(parsed, graph):
+ report = HealthAnalyzer(graph, parsed_files=parsed).analyze()
+ return [f for f in report.findings if f.biomarker_type == "untested_complexity"]
+
+
+def test_a_test_calling_the_function_clears_it(tmp_path) -> None:
+ assert _crap_findings(_tree(tmp_path), _graph(calls=True)) == []
+
+
+def test_without_the_call_the_same_function_fires(tmp_path) -> None:
+ found = _crap_findings(_tree(tmp_path), _graph(calls=False))
+ assert [(f.file_path, f.function_name) for f in found] == [("src/router.py", "route")]
+ # The test imports the module, so the file is paired: reach, not a direct test.
+ assert found[0].details["coverage_tier"] == "reached"
+
+
+def test_a_stored_report_measures_the_function(tmp_path) -> None:
+ from repowise.core.analysis.health.coverage.model import coverage_map_entry, file_coverage
+
+ lines = range(1, 25)
+ for covered, expected in ((lines, []), ((), ["measured"])):
+ entry = coverage_map_entry(file_coverage("src/router.py", covered, lines), "lcov")
+ report = HealthAnalyzer(
+ _graph(calls=False),
+ parsed_files=_tree(tmp_path / str(len(expected))),
+ coverage_map={"src/router.py": entry},
+ ).analyze()
+ found = [f for f in report.findings if f.biomarker_type == "untested_complexity"]
+ assert [f.details["coverage_basis"] for f in found] == expected
+
+
+def test_a_test_two_calls_away_is_reach_not_a_direct_test(tmp_path) -> None:
+ found = _crap_findings(_tree(tmp_path), _graph(calls=False, via_helper=True))
+ assert [f.details["coverage_tier"] for f in found] == ["reached"]