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(cli): use DeadCodeFinding.kind in export --full JSON (#1416)

Felix-Ayushe405d65fbe23
diff --git a/packages/cli/src/repowise/cli/commands/export_cmd.py b/packages/cli/src/repowise/cli/commands/export_cmd.py
index 5f104959b..11e792061 100644
--- a/packages/cli/src/repowise/cli/commands/export_cmd.py
+++ b/packages/cli/src/repowise/cli/commands/export_cmd.py
@@ -170,7 +170,7 @@ def export_command(
{
"file_path": f.file_path,
"symbol_name": f.symbol_name,
- "finding_type": f.finding_type,
+ "kind": f.kind,
"confidence": f.confidence,
"safe_to_delete": f.safe_to_delete,
}
diff --git a/tests/unit/cli/test_export_full_dead_code.py b/tests/unit/cli/test_export_full_dead_code.py
new file mode 100644
index 000000000..1dca16580
--- /dev/null
+++ b/tests/unit/cli/test_export_full_dead_code.py
@@ -0,0 +1,42 @@
+"""Regression: ``repowise export --format json --full`` must not crash on dead code."""
+
+from __future__ import annotations
+
+from pathlib import Path
+from types import SimpleNamespace
+
+from repowise.core.persistence.models import DeadCodeFinding
+
+
+def test_dead_code_finding_model_exposes_kind_not_finding_type():
+ """ORM contract the full-JSON export must follow."""
+ assert hasattr(DeadCodeFinding, "kind")
+ assert not hasattr(DeadCodeFinding, "finding_type")
+
+
+def test_full_export_dead_code_projection_uses_kind():
+ """Projection mirrors export_cmd: read ``kind``, never ``finding_type``."""
+ row = SimpleNamespace(
+ file_path="pkg/orphan.py",
+ symbol_name="unused",
+ kind="unused_export",
+ confidence=0.9,
+ safe_to_delete=True,
+ )
+ out = {
+ "file_path": row.file_path,
+ "symbol_name": row.symbol_name,
+ "kind": row.kind,
+ "confidence": row.confidence,
+ "safe_to_delete": row.safe_to_delete,
+ }
+ assert out["kind"] == "unused_export"
+
+
+def test_export_cmd_source_does_not_reference_finding_type():
+ src = (
+ Path(__file__).resolve().parents[3]
+ / "packages/cli/src/repowise/cli/commands/export_cmd.py"
+ ).read_text(encoding="utf-8")
+ assert "f.finding_type" not in src
+ assert "f.kind" in src