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
test(dead-code): a whole unreachable file is review-only, so its lines are not deletable (#2716)
Raghav Chamadiyac4a2ab0a5d81
diff --git a/tests/unit/dead_code/test_line_counts.py b/tests/unit/dead_code/test_line_counts.pyindex 97e9c73fe..6f688438c 100644--- a/tests/unit/dead_code/test_line_counts.py+++ b/tests/unit/dead_code/test_line_counts.py@@ -61,7 +61,8 @@ def test_nineteen_line_file_counts_nineteen_lines():by_path, report = _unreachable(g, source_map={"pkg/a.py": source + b"\n", "pkg/b.py": source})assert by_path["pkg/a.py"].lines == 19assert by_path["pkg/b.py"].lines == 19- assert report.deletable_lines == 38+ # Whole files are review-only, so none of their lines count as deletable.+ assert report.deletable_lines == 0def test_file_counted_from_disk_without_source_map(tmp_path):@@ -74,12 +75,11 @@ def test_file_counted_from_disk_without_source_map(tmp_path):def test_unreadable_file_is_unknown_not_guessed():g = _build_graph(nodes={"pkg/gone.py": _file(9), "pkg/a.py": _file(1)})- by_path, report = _unreachable(g, source_map={"pkg/a.py": b"x = 1\n"})+ by_path, _ = _unreachable(g, source_map={"pkg/a.py": b"x = 1\n"})gone = by_path["pkg/gone.py"]assert gone.lines is Noneassert "Line count unavailable: source was not read" in gone.evidence- # The total sums what is known rather than failing on the unknown.- assert report.deletable_lines == 1+ assert by_path["pkg/a.py"].lines == 1def test_zombie_package_sums_real_file_lines():diff --git a/tests/unit/dead_code/test_path_mentions.py b/tests/unit/dead_code/test_path_mentions.pyindex 964154053..d264e077b 100644--- a/tests/unit/dead_code/test_path_mentions.py+++ b/tests/unit/dead_code/test_path_mentions.py@@ -85,7 +85,7 @@ def test_a_file_naming_itself_is_not_a_use():assert finding.confidence == 1.0-def test_a_truly_dead_file_through_the_analyzer_stays_deletion_ready():+def test_a_truly_dead_file_through_the_analyzer_keeps_full_confidence():g = _build_graph(nodes={"pkg/used.py": {"is_entry_point": True, "symbols": []},@@ -113,7 +113,8 @@ def test_a_truly_dead_file_through_the_analyzer_stays_deletion_ready():})by_path = {f.file_path: f for f in report.findings if f.kind == DeadCodeKind.UNREACHABLE_FILE}- assert by_path["pkg/old.py"].safe_to_delete is True+ # A whole file is review-only, however sure the analyzer is.+ assert by_path["pkg/old.py"].safe_to_delete is Falseassert by_path["pkg/old.py"].confidence == 1.0assert by_path["pkg/listed.py"].confidence == RISK_CAP_CONFIDENCEassert by_path["pkg/listed.py"].safe_to_delete is False