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(refactoring): suggest no validation command for a language with no known runner (#2930)
Yang Baiba57fb8d2d9b
diff --git a/packages/core/src/repowise/core/analysis/health/refactoring/recommendations.py b/packages/core/src/repowise/core/analysis/health/refactoring/recommendations.pyindex e5833d879..e65fcf5c5 100644--- a/packages/core/src/repowise/core/analysis/health/refactoring/recommendations.py+++ b/packages/core/src/repowise/core/analysis/health/refactoring/recommendations.py@@ -528,6 +528,10 @@ def _commands(tests: list[str], files: list[str], *, total: int | None = None) -read as a complete validation run while silently skipping the rest, so theselection widens to the files those tests live in: bounded by file countrather than test count, and never narrower than the evidence.++ An empty list means the plan has no command to suggest. Nothing here looks+ at the repository's tooling, so a language other than Python or JS/TS gets+ none in place of a guess that would fail when run."""if total is not None and total > len(tests):tests = sorted({test.split("::", 1)[0] for test in tests})@@ -546,7 +550,7 @@ def _commands(tests: list[str], files: list[str], *, total: int | None = None) -return ["pytest"]if any(path.endswith((".ts", ".tsx", ".js", ".jsx")) for path in files):return ["npm test", "npm run type-check"]- return ["npm run test"]+ return []def _line_ranges(suggestion: RefactoringSuggestion) -> dict[str, set[int] | None]:diff --git a/tests/unit/health/test_recommendations.py b/tests/unit/health/test_recommendations.pyindex 12e2b4906..88044c801 100644--- a/tests/unit/health/test_recommendations.py+++ b/tests/unit/health/test_recommendations.py@@ -388,6 +388,36 @@ def test_a_truncated_test_list_widens_the_command_past_the_shown_tests() -> Noneassert plan.commands == ["pytest tests/test_orders.py"]+def test_a_plan_in_a_language_with_no_known_runner_suggests_no_command() -> None:+ """The fallback used to be ``npm run test`` for every file that was not+ Python or JS, in repos with no ``package.json``. A wrong command is worse+ than none: every consumer treats an empty list as nothing to suggest."""+ for path in ("src/Foo/Bar.cs", "src/native/foo.cpp", "server/Translog.java", "a/b.go"):+ plan = build_validation_plan(_plan("target", file_path=path), {}, {})+ assert plan.commands == [], path+++def test_tests_in_a_language_with_no_known_runner_suggest_no_command() -> None:+ reached = ReachedBy(+ via="call-graph",+ total=1,+ tests=["tests/BarTests.cs::Ok"],+ all_tests=["tests/BarTests.cs::Ok"],+ )+ plan = build_validation_plan(+ _plan("target", file_path="src/Foo/Bar.cs"), {}, {"src/Foo/Bar.cs": reached}+ )+ assert plan.tests == ["tests/BarTests.cs::Ok"]+ assert plan.commands == []+++def test_python_and_js_plans_keep_their_default_commands() -> None:+ python = build_validation_plan(_plan("target", file_path="a/b.py"), {}, {})+ assert python.commands == ["pytest"]+ typescript = build_validation_plan(_plan("target", file_path="web/app.ts"), {}, {})+ assert typescript.commands == ["npm test", "npm run type-check"]++def test_an_untruncated_test_list_keeps_the_precise_command() -> None:reached = ReachedBy(via="call-graph",