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
feat(health): promote PHP to Good tier with complexity, LCOM4, and assertion block support (#3089)
Rishabh Mishra185c9fd8dcd9
diff --git a/docs/layers/LANGUAGE_SUPPORT.md b/docs/layers/LANGUAGE_SUPPORT.mdindex 5e739fd83..b587b60e2 100644--- a/docs/layers/LANGUAGE_SUPPORT.md+++ b/docs/layers/LANGUAGE_SUPPORT.md@@ -57,7 +57,7 @@ resolution and health markers are all static.| Tier | Languages | What you get ||------|-----------|--------------|| **Full** (13) | Python · TypeScript · JavaScript · Svelte · Vue · Java · Kotlin · Go · Rust · C++ · C# · Scala · Ruby | The whole pipeline: AST symbols, import resolution, a resolved call graph, heritage, docstrings, framework edges and code-health markers |-| **Good** (11) | C · Swift · PHP · Dart · Object Pascal · COBOL · GDScript · VB.NET · Elixir · F# · Objective-C | Everything above except the full health suite. Dart and Object Pascal get health markers; C, F# and Objective-C get the complexity-derived ones; the rest get none yet |+| **Good** (11) | C · Swift · PHP · Dart · Object Pascal · COBOL · GDScript · VB.NET · Elixir · F# · Objective-C | Everything above except the full health suite. Dart, Object Pascal and PHP get health markers; C, F# and Objective-C get the complexity-derived ones; the rest get none yet || **Partial** (2) | Luau / Roblox · Razor / Blazor | Luau: AST symbols and `require()` resolution (Rojo and `.luaurc` aware), no health markers. Razor: a component symbol per file, call edges from `@code` blocks and component tags, C# health markers, no import edges yet || **Lightweight** (6) | Clojure · Haskell · Lean 4 · Erlang · HTML · QML | A real file-to-file import graph, no symbol-level claims || **Structural** (8) | R · Zig · Julia · Elm · OCaml · Crystal · Nim · D | Git history only: blame, hotspots, co-change. No AST parsing |@@ -303,6 +303,7 @@ This table is why a language is Full and not Good.| Dart | ✅ | n/a | ✅ | no | no | no | ✅ || Object Pascal | ✅ | n/a | ✅ | n/a | n/a | no | ✅ || Razor | ✅ | n/a | n/a | n/a | n/a | no | ✅ |+| PHP | ✅ | ✅ | ✅ | no | no | no | no || C · F# · Objective-C | ✅ | no | no | no | no | no | no || Shell | ✅ | n/a | n/a | n/a | n/a | n/a | n/a |diff --git a/packages/core/src/repowise/core/analysis/health/asserts/lexicon.py b/packages/core/src/repowise/core/analysis/health/asserts/lexicon.pyindex 670a35c33..1eb6e78a6 100644--- a/packages/core/src/repowise/core/analysis/health/asserts/lexicon.py+++ b/packages/core/src/repowise/core/analysis/health/asserts/lexicon.py@@ -271,6 +271,10 @@ FLAG_CHECK_PATTERNS: dict[str, tuple[str, ...]] = {),"rust": (rf"^assert!{_CALL_ON_NAME}{_END}",),"go": (r"^(?:assert|require)\.(?:Not)?(?:Nil|True|False)\(\s*\w+\s*,\s*!?\w+\s*\)$",),+ "php": (+ rf"^(?:\$this->|self::|static::)?assert(?:Not)?Null\(\s*(?:{_MSG}\s*,\s*)?!?\$?\w+\s*(?:,\s*{_MSG})?\s*\){_END}",+ rf"^(?:\$this->|self::|static::)?assert(?:True|False)\(\s*(?:{_MSG}\s*,\s*)?!?\$?\w+\s*(?:,\s*{_MSG})?\s*\){_END}",+ ),}for _alias, _base in (("tsx", "typescript"), ("javascript", "typescript"), ("jsx", "typescript")):FLAG_CHECK_PATTERNS[_alias] = FLAG_CHECK_PATTERNS[_base]diff --git a/packages/core/src/repowise/core/analysis/health/complexity/README.md b/packages/core/src/repowise/core/analysis/health/complexity/README.mdindex 1dcb06ef2..1b2cb268f 100644--- a/packages/core/src/repowise/core/analysis/health/complexity/README.md+++ b/packages/core/src/repowise/core/analysis/health/complexity/README.md@@ -181,11 +181,12 @@ false positive, and no vocabulary row can give it any. (Languages without an `exKotlin, where the call node sits directly in the statement list — arehandled too: the call node is matched as the statement itself.)-Ships control-flow + assertion mappings for **all eleven full-tier-languages** (Python, TypeScript, JavaScript, Go, Java, Kotlin, Rust, C++,-C#, Scala, Ruby) plus the `tsx`/`jsx` aliases and Dart; class-level (LCOM4 /-god-class) mappings for all of those except **Go** (methods attach to a type-via an external receiver, so there is no single grouping node). Ruby maps+Ships control-flow + assertion mappings for eleven full-tier languages+(Python, TypeScript, JavaScript, Go, Java, Kotlin, Rust, C++, C#, Scala,+Ruby), the `tsx`/`jsx` aliases, and three Good-tier languages: Dart, Object+Pascal and PHP. Class-level (LCOM4 / god-class) mappings cover all of those+except **Go** (methods attach to a type via an external receiver, so there is+no single grouping node) and Object Pascal. Ruby maps`class_kinds` (size / god-class facts) but leaves `member_access_kinds`unmapped on purpose — receiver-less `@ivar` idiom — so its LCOM4 stays at theno-signal valve. Adding more languages — any tier — is purely additive indiff --git a/packages/core/src/repowise/core/analysis/health/complexity/assertions.py b/packages/core/src/repowise/core/analysis/health/complexity/assertions.pyindex 7c6378d2b..49085c90a 100644--- a/packages/core/src/repowise/core/analysis/health/complexity/assertions.py+++ b/packages/core/src/repowise/core/analysis/health/complexity/assertions.py@@ -62,6 +62,16 @@ _NARROW = 2_VERIFICATION = 3+_PHP_CALL_KINDS = frozenset(+ {+ "function_call_expression",+ "member_call_expression",+ "scoped_call_expression",+ "nullsafe_member_call_expression",+ }+)++def _callee_matches_assert(call_node: Node) -> bool:"""True if any identifier in *call_node*'s callee chain is assert-ish.@@ -73,10 +83,19 @@ def _callee_matches_assert(call_node: Node) -> bool:# Fallback when no ``function``/``macro`` field is exposed: the first# named child is usually the callee.roots = [callee] if callee is not None else [c for c in call_node.children if c.is_named][:1]+ # PHP spells identifiers ``name`` (not ``*identifier``), and a method+ # call keeps its method name in a ``name`` field. Both are gated on PHP's+ # call node kinds, which no other mapped grammar has.+ is_php_call = call_node.type in _PHP_CALL_KINDS+ if is_php_call and call_node.type != "function_call_expression":+ name_node = call_node.child_by_field_name("name")+ if name_node is not None:+ roots.append(name_node)stack: list[Node] = list(roots)while stack:node = stack.pop()- if node.type.endswith(_IDENTIFIER_SUFFIX) and node.text is not None:+ is_ident = node.type.endswith(_IDENTIFIER_SUFFIX) or (is_php_call and node.type == "name")+ if is_ident and node.text is not None:name = node.text.decode("utf-8", errors="replace").lower()if any(name.startswith(p) for p in NARROW_PREFIXES):return Truediff --git a/packages/core/src/repowise/core/analysis/health/complexity/cyclomatic.py b/packages/core/src/repowise/core/analysis/health/complexity/cyclomatic.pyindex 6cb79b5b6..a714d6b05 100644--- a/packages/core/src/repowise/core/analysis/health/complexity/cyclomatic.py+++ b/packages/core/src/repowise/core/analysis/health/complexity/cyclomatic.py@@ -48,7 +48,16 @@ _BODY_FIELD_NAMES = (# node types for the same construct -- either can be a chain's last arm# (bare ``if`` when it has no further ``else``, ``ifElse`` when it does)._ELSE_IF_NODE_KINDS = frozenset(- {"if_statement", "if_expression", "elif_clause", "elsif", "if_let_expression", "if", "ifElse"}+ {+ "if_statement",+ "if_expression",+ "elif_clause",+ "elsif",+ "else_if_clause",+ "if_let_expression",+ "if",+ "ifElse",+ })# Token spelling(s) an else-if continuation's previous sibling carries when@@ -88,6 +97,8 @@ def _is_elif_continuation(node: Node) -> bool:- Python: a dedicated ``elif_clause`` node (always a continuation).- Ruby: a dedicated ``elsif`` node (always a continuation).+ - PHP: a dedicated ``else_if_clause`` node for ``elseif`` (always a+ continuation); ``else if`` is wrapped in an ``else_clause`` as below.- TypeScript / Rust / C++: the else-if is wrapped in an ``else_clause``.- Java / Go / C# / Dart / Kotlin / Pascal: the else-if node is thesibling that immediately follows the parent ``if``'s else token@@ -95,7 +106,7 @@ def _is_elif_continuation(node: Node) -> bool:"""if node.type not in _ELSE_IF_NODE_KINDS:return False- if node.type in ("elif_clause", "elsif"):+ if node.type in ("elif_clause", "elsif", "else_if_clause"):return Trueparent = node.parentif parent is None:diff --git a/packages/core/src/repowise/core/analysis/health/complexity/languages.py b/packages/core/src/repowise/core/analysis/health/complexity/languages.pyindex 4ad294053..e8a3ac860 100644--- a/packages/core/src/repowise/core/analysis/health/complexity/languages.py+++ b/packages/core/src/repowise/core/analysis/health/complexity/languages.py@@ -1182,6 +1182,38 @@ _OBJC = LanguageNodeMap()+_PHP = LanguageNodeMap(+ function_kinds=frozenset({"function_definition", "method_declaration"}),+ lambda_kinds=frozenset({"anonymous_function", "arrow_function"}),+ branch_kinds=frozenset({"if_statement", "else_if_clause", "conditional_expression"}),+ loop_kinds=frozenset({"for_statement", "foreach_statement", "while_statement", "do_statement"}),+ try_kinds=frozenset({"try_statement"}),+ catch_kinds=frozenset({"catch_clause"}),+ switch_kinds=frozenset({"switch_statement", "match_expression"}),+ case_kinds=frozenset({"case_statement", "match_conditional_expression"}),+ boolean_operator_kinds=frozenset(),+ boolean_operator_text_kinds=frozenset({"binary_expression"}),+ class_kinds=frozenset(+ {"class_declaration", "trait_declaration", "interface_declaration", "enum_declaration"}+ ),+ self_identifiers=frozenset({"$this"}),+ member_access_kinds=frozenset(+ {"member_access_expression", "member_call_expression", "nullsafe_member_access_expression"}+ ),+ assert_call_kinds=frozenset(+ {"member_call_expression", "scoped_call_expression", "function_call_expression"}+ ),+ call_kinds=frozenset(+ {+ "member_call_expression",+ "scoped_call_expression",+ "function_call_expression",+ "nullsafe_member_call_expression",+ }+ ),+)++LANGUAGE_MAPS: dict[str, LanguageNodeMap] = {"python": _PY,"typescript": _TS,@@ -1211,6 +1243,7 @@ LANGUAGE_MAPS: dict[str, LanguageNodeMap] = {# No "elixir" entry on purpose. See the note above ``_FSHARP``."fsharp": _FSHARP,"objectivec": _OBJC,+ "php": _PHP,}diff --git a/tests/fixtures/lang_samples/php/assertions.php b/tests/fixtures/lang_samples/php/assertions.phpnew file mode 100644index 000000000..a63acf933--- /dev/null+++ b/tests/fixtures/lang_samples/php/assertions.php@@ -0,0 +1,20 @@+<?php+use PHPUnit\Framework\TestCase;++class AssertionsTest extends TestCase {+ public function testManyAsserts(): void {+ $result = 42;+ $this->assertEquals(42, $result);+ $this->assertTrue($result > 0);+ $this->assertFalse($result < 0);+ $this->assertNotNull($result);+ $this->assertGreaterThan(10, $result);+ }++ public function testFewAsserts(): void {+ $result = 42;+ $this->assertEquals(42, $result);+ echo "computed: " . $result;+ self::assertNotNull($result);+ }+}diff --git a/tests/fixtures/lang_samples/php/classes.php b/tests/fixtures/lang_samples/php/classes.phpnew file mode 100644index 000000000..668446115--- /dev/null+++ b/tests/fixtures/lang_samples/php/classes.php@@ -0,0 +1,65 @@+<?php+// Class-metrics fixture: LCOM4 and class-level properties for PHP.++class CohesiveClass {+ private int $total = 0;++ public function add(int $x): void {+ $this->total += $x;+ }++ public function getTotal(): int {+ return $this->total;+ }++ public function reset(): void {+ $this->total = 0;+ $this->helper();+ }++ private function helper(): void {+ // internal helper+ }+}++class SplitClass {+ private int $alpha = 0;+ private int $beta = 0;++ public function stepAlpha(): void {+ $this->alpha += 1;+ }++ public function getAlpha(): int {+ return $this->alpha;+ }++ public function stepBeta(): void {+ $this->beta += 2;+ }++ public function getBeta(): int {+ return $this->beta;+ }+}++trait LoggableTrait {+ private string $prefix = "[LOG]";++ public function log(string $msg): void {+ echo $this->prefix . ": " . $msg;+ }++ public function setPrefix(string $p): void {+ $this->prefix = $p;+ }+}++interface WorkerInterface {+ public function performWork(): void;+}++enum Priority {+ case Low;+ case High;+}diff --git a/tests/fixtures/lang_samples/php/clean.php b/tests/fixtures/lang_samples/php/clean.phpnew file mode 100644index 000000000..ac5985f51--- /dev/null+++ b/tests/fixtures/lang_samples/php/clean.php@@ -0,0 +1,9 @@+<?php++function greet(string $name): string {+ return "Hello, " . $name;+}++function sum(int $a, int $b): int {+ return $a + $b;+}diff --git a/tests/fixtures/lang_samples/php/nested.php b/tests/fixtures/lang_samples/php/nested.phpnew file mode 100644index 000000000..e1ce12308--- /dev/null+++ b/tests/fixtures/lang_samples/php/nested.php@@ -0,0 +1,100 @@+<?php+// Control-flow fixture for the PHP complexity walker.++function deeply_nested($x) {+ if ($x > 0) {+ while ($x > 0) {+ if ($x > 1) {+ if ($x > 2) {+ echo $x;+ }+ }+ $x--;+ }+ }+}++function many_branches($a, $b) {+ if ($a === null) {+ return 0;+ }+ if ($a > 0 && $b > 0) {+ return 1;+ } elseif ($a > 0 || $b > 0) {+ return 2;+ } else if ($a === 0) {+ return 3;+ } else {+ return 4;+ }+}++function wordy($a, $b) {+ return ($a and $b) or $a;+}++function shallow($x) {+ return $x;+}++function lambda_and_arrow($items) {+ $anon = function($x) {+ if ($x > 0) {+ return $x * 2;+ }+ return 0;+ };+ $arrow = fn($x) => $x > 0 ? $x * 2 : 0;+ return array_map($arrow, array_map($anon, $items));+}++function match_and_switch($x) {+ switch ($x) {+ case 1:+ $res = 'one';+ break;+ case 2:+ $res = 'two';+ break;+ default:+ $res = 'other';+ break;+ }++ $matched = match ($x) {+ 1 => 'one',+ 2, 3 => 'two_or_three',+ default => 'other',+ };++ return $res . $matched;+}++function try_catch_finally($path) {+ try {+ $data = file_get_contents($path);+ if ($data === false) {+ throw new Exception("read failed");+ }+ } catch (InvalidArgumentException $e) {+ echo "invalid: " . $e->getMessage();+ } catch (Exception $e) {+ echo "error: " . $e->getMessage();+ } finally {+ echo "cleanup";+ }+}++function loops_galore($items) {+ $count = 0;+ for ($i = 0; $i < count($items); $i++) {+ $count += $items[$i];+ }+ foreach ($items as $k => $v) {+ $count += $v;+ }+ do {+ $count--;+ } while ($count > 100);+ return $count;+}diff --git a/tests/unit/health/test_complexity_walker.py b/tests/unit/health/test_complexity_walker.pyindex ae1820da1..d35857ab7 100644--- a/tests/unit/health/test_complexity_walker.py+++ b/tests/unit/health/test_complexity_walker.py@@ -860,3 +860,60 @@ def test_ruby_assertion_blocks():assert many.assertion_blocks[0][2] == 5few = _find(results, "test_few_asserts")assert few is not None and few.assertion_blocks == []+++def test_php_nesting_and_ccn():+ results = _walk("php/nested.php", "php")+ deep = _find(results, "deeply_nested")+ assert deep is not None+ assert deep.ccn == 5, f"expected CCN 5, got {deep.ccn}"+ assert deep.max_nesting == 4, f"expected nesting 4, got {deep.max_nesting}"+ many = _find(results, "many_branches")+ assert many is not None+ # if + if + && + elseif + || + else if + base path+ assert many.ccn == 7, f"expected CCN 7, got {many.ccn}"+ assert many.max_nesting == 1, f"expected nesting 1, got {many.max_nesting}"+ wordy = _find(results, "wordy")+ assert wordy is not None and wordy.ccn == 3 # and + or+ shallow = _find(results, "shallow")+ assert shallow is not None and shallow.max_nesting == 0+ assert shallow.param_count == 1+ loops = _find(results, "loops_galore")+ assert loops is not None+ assert loops.ccn == 4 # for + foreach + do-while + 1+ assert loops.max_nesting == 1+ tc = _find(results, "try_catch_finally")+ assert tc is not None+ assert tc.ccn == 4 # if + 2 catch clauses + 1+++def test_php_lambdas_and_closures():+ results = _walk("php/nested.php", "php")+ fn = _find(results, "lambda_and_arrow")+ assert fn is not None+ # anonymous_function branch rolls into lambda_and_arrow+ assert fn.ccn >= 3+++def test_php_classes_lcom4():+ classes = _walk_classes("php/classes.php", "php")+ cohesive = classes.get("CohesiveClass")+ split = classes.get("SplitClass")+ assert cohesive is not None and split is not None+ assert cohesive.method_count == 4+ assert split.method_count == 4+ assert cohesive.lcom4 == 1+ assert split.lcom4 >= 2+ trait = classes.get("LoggableTrait")+ assert trait is not None+ assert trait.method_count == 2+++def test_php_assertion_blocks():+ results = _walk("php/assertions.php", "php")+ many = _find(results, "testManyAsserts")+ assert many is not None+ assert many.assertion_blocks, "expected a run of assert calls"+ assert many.assertion_blocks[0][2] == 5+ few = _find(results, "testFewAsserts")+ assert few is not None and few.assertion_blocks == []diff --git a/tests/unit/health/test_duplicated_assertion_dialects.py b/tests/unit/health/test_duplicated_assertion_dialects.pyindex 51bc5d94e..fc9ce1d5e 100644--- a/tests/unit/health/test_duplicated_assertion_dialects.py+++ b/tests/unit/health/test_duplicated_assertion_dialects.py@@ -76,6 +76,23 @@ _CASES = {],["assert r is not None", "assert done", "assert not err", "assert ok, 'message'"],),+ "php": (+ "tests/FooTest.php",+ "<?php\nclass FooTest {{\n public function testIt() {{\n{body}\n }}\n}}\n",+ [+ "$this->assertEquals(5, $r->count);",+ "$this->assertEquals('a', $r->name);",+ "$this->assertEquals(2, $r->size());",+ "$this->assertContains('x', $r->tags);",+ "$this->assertEquals(\n 1,\n $r->first());",+ ],+ [+ "$this->assertNotNull($r);",+ "$this->assertTrue($done);",+ "$this->assertNull($err);",+ "self::assertFalse($failed);",+ ],+ ),}@@ -117,6 +134,8 @@ def test_five_real_checks_are_reported_four_are_not(language: str):("csharp", "Assert.Equal(expected, Compute());"),("python", "assert x == compute()"),("typescript", "expect(x).toBe(5);"),+ ("php", "$this->assertEquals(5, getCount());"),+ ("php", "$this->assertNull($x->getY());"),],)def test_a_value_check_is_not_a_flag_check(language: str, line: str):@@ -133,6 +152,9 @@ def test_a_value_check_is_not_a_flag_check(language: str, line: str):("javascript", "assert.ok(done);"),("rust", "assert!(ok);"),("go", "require.NotNil(t, err)"),+ ("php", "$this->assertNotNull($x);"),+ ("php", "self::assertTrue($done);"),+ ("php", "static::assertNull($err, 'custom msg');"),],)def test_flag_checks_per_language(language: str, line: str):diff --git a/tests/unit/health/test_language_node_maps.py b/tests/unit/health/test_language_node_maps.pyindex 64c0afff2..0440c032f 100644--- a/tests/unit/health/test_language_node_maps.py+++ b/tests/unit/health/test_language_node_maps.py@@ -417,3 +417,164 @@ public class A {}"""assert _rows("typescript", typescript, "ts")["pick"] == _rows("java", java, "java")["pick"] == 4+++# --------------------------------------------------------------------------- #+# PHP+# --------------------------------------------------------------------------- #++_PHP_CASES: list[tuple[str, str, dict[str, int]]] = [+ (+ "functions and methods are walked with CCN entry 1",+ """<?php+function standalone($x) {+ return $x;+}+class Service {+ public function handle($x) {+ return $x;+ }+}+""",+ {"standalone": 1, "handle": 1},+ ),+ (+ "if, elseif, else if and ternaries add branch points",+ """<?php+function branches($a, $b) {+ if ($a > 0) {+ return 1;+ } elseif ($a < 0) {+ return 2;+ } else if ($b > 0) {+ return 3;+ }+ return $b ? 4 : 5;+}+""",+ {"branches": 5},+ ),+ (+ "boolean operators &&, ||, and, or add to CCN",+ """<?php+function booleans($a, $b, $c, $d) {+ if ($a && $b) {+ return 1;+ }+ if ($c || $d) {+ return 2;+ }+ return ($a and $b) or ($c and $d);+}+""",+ {"booleans": 8},+ ),+ (+ "xor does not short-circuit, so it adds no path; and / or still do",+ """<?php+function wordy($a, $b, $c) {+ if ($a xor $b) {+ return 1;+ }+ return $a and $b or $c;+}+""",+ {"wordy": 4},+ ),+ (+ "loops and try-catch add complexity",+ """<?php+function control_flow($items) {+ try {+ foreach ($items as $item) {+ while ($item > 0) {+ $item--;+ }+ }+ } catch (Exception $e) {+ echo $e->getMessage();+ }+}+""",+ {"control_flow": 4},+ ),+ (+ "match and switch expressions count dispatch",+ """<?php+function dispatch($x) {+ switch ($x) {+ case 1:+ return 10;+ case 2:+ return 20;+ default:+ return 0;+ }+}+function matching($x) {+ return match ($x) {+ 1 => 10,+ 2, 3 => 20,+ default => 0,+ };+}+""",+ {"dispatch": 2, "matching": 2},+ ),+]+++ ("source", "expected"),+ [(src, exp) for _, src, exp in _PHP_CASES],+ ids=[label for label, _, _ in _PHP_CASES],+)+def test_php_complexity(source: str, expected: dict[str, int]) -> None:+ _require_language("php")+ assert _rows("php", source, "php") == expected+++def test_php_name_nodes_count_only_in_php_calls() -> None:+ """The ``name`` identifier match is gated to PHP's call kinds.++ No other mapped grammar has a ``name`` node or PHP's call node kinds, so+ their assertion counting cannot change through that gate.+ """+ from repowise.core.analysis.health.complexity.assertions import _PHP_CALL_KINDS+ from repowise.core.analysis.health.complexity.languages import LANGUAGE_MAPS+ from repowise.core.ingestion.parser import _get_language, grammar_tag_for++ php_only = _PHP_CALL_KINDS | {"name"}+ for language in LANGUAGE_MAPS:+ if language == "php":+ continue+ try:+ grammar = _get_language(grammar_tag_for(language, "x"))+ except Exception:+ continue+ if grammar is None:+ continue+ kinds = {+ grammar.node_kind_for_id(i)+ for i in range(grammar.node_kind_count)+ if grammar.node_kind_is_named(i)+ }+ assert not kinds & php_only, language+++def test_php_argument_named_assert_is_not_an_assertion() -> None:+ _require_language("php")+ source = b"""<?php+class FooTest {+ public function testIt() {+ $this->assertSame(1, $x);+ $this->assertSame(2, $y);+ $this->assertSame(3, $z);+ helper($assertion);+ helper($assertion);+ }+}+"""+ fc = walk_file("FooTest.php", "php", source)+ (fn,) = fc.functions+ assert fn.assertion_count == 3diff --git a/tests/unit/health/test_unanalysed_languages.py b/tests/unit/health/test_unanalysed_languages.pyindex 5a491b1f9..b1390ea05 100644--- a/tests/unit/health/test_unanalysed_languages.py+++ b/tests/unit/health/test_unanalysed_languages.py@@ -27,12 +27,12 @@ from repowise.core.analysis.health.trends import snapshot_fieldsfrom repowise.core.pipeline.incremental import _numbers_moved[email protected]("language", ["python", "typescript", "csharp", "razor", "sql"])[email protected]("language", ["python", "typescript", "csharp", "razor", "sql", "php"])def test_languages_health_walks_have_a_dialect(language: str) -> None:assert has_health_dialect(language)[email protected]("language", ["php", "swift", "elixir", "markdown", "", None])[email protected]("language", ["swift", "elixir", "markdown", "", None])def test_languages_nothing_walks_have_none(language: str | None) -> None:assert not has_health_dialect(language)@@ -66,8 +66,10 @@ def _evaluate(path: str, language: str, source: bytes, tmp_path) -> HealthFileMereturn metric-def test_a_php_file_is_stored_with_no_score_and_no_complexity(tmp_path) -> None:- metric = _evaluate("src/Big.php", "php", b"<?php\nfunction f($a) { if ($a) { return 1; } }\n", tmp_path)+def test_an_unsupported_language_file_is_stored_with_no_score_and_no_complexity(tmp_path) -> None:+ metric = _evaluate(+ "src/Big.ex", "elixir", b"defmodule Big do\ndef f(a), do: a\nend\n", tmp_path+ )assert metric.score is Noneassert metric.max_ccn is None and metric.max_nesting is Noneassert all(getattr(metric, name) is None for name in SCORE_FIELDS)@@ -97,9 +99,9 @@ def test_kpis_leave_unscored_files_out() -> None:_metric("a.py", 4.0, nloc=100),_metric("b.py", 8.0, nloc=100),# Huge and unscored: counted as 10.0 it would drag the average to ~9.- _metric("Big.php", None, nloc=10_000),+ _metric("Big.ex", None, nloc=10_000),]- kpis = compute_kpis(rows, {"a.py", "Big.php"})+ kpis = compute_kpis(rows, {"a.py", "Big.ex"})assert kpis["average_health"] == 6.0assert kpis["hotspot_health"] == 4.0assert kpis["file_count"] == 2@@ -108,12 +110,12 @@ def test_kpis_leave_unscored_files_out() -> None:def test_a_repository_of_only_unscored_files_has_no_average() -> None:- kpis = compute_kpis([_metric("A.php", None), _metric("B.php", None)], {"A.php"})+ kpis = compute_kpis([_metric("A.ex", None), _metric("B.ex", None)], {"A.ex"})assert kpis["average_health"] is Noneassert kpis["hotspot_health"] is Noneassert kpis["unanalysed_file_count"] == 2# No trend point for a number nobody measured.- assert snapshot_fields(kpis, [_metric("A.php", None)], []) is None+ assert snapshot_fields(kpis, [_metric("A.ex", None)], []) is Nonedef test_an_empty_repository_has_no_average_either() -> None:@@ -125,19 +127,19 @@ def test_an_empty_repository_has_no_average_either() -> None:def test_unscored_files_are_never_the_worst_or_a_hotspot() -> None:- rows = [_metric("Big.php", None), _metric("a.py", 9.0)]+ rows = [_metric("Big.ex", None), _metric("a.py", 9.0)]assert worst_metric(rows, {}).file_path == "a.py"- assert worst_metric([_metric("Big.php", None)], {}) is None- assert hotspot_health(rows, {"Big.php"}) is None+ assert worst_metric([_metric("Big.ex", None)], {}) is None+ assert hotspot_health(rows, {"Big.ex"}) is Nonedef test_unscored_files_have_no_band() -> None:- dist = distribution([_metric("Big.php", None), _metric("a.py", 9.0)])+ dist = distribution([_metric("Big.ex", None), _metric("a.py", 9.0)])assert sum(band["files"] for band in dist["bands"].values()) == 1def test_snapshot_score_map_skips_unscored_files() -> None:- rows = [_metric("Big.php", None), _metric("a.py", 9.0)]+ rows = [_metric("Big.ex", None), _metric("a.py", 9.0)]fields = snapshot_fields(compute_kpis(rows, set()), rows, [])assert fields is not Noneassert fields["per_file_scores"] == {"a.py": 9.0}@@ -154,7 +156,7 @@ def test_an_update_clears_a_stored_ten_for_an_unscored_file() -> None:def test_walk_of_an_unsupported_language_is_empty() -> None:"""Why the score is meaningless: no function is ever measured."""- fcx = walk_file("/tmp/x.php", "php", b"<?php\nfunction f() { if (1) {} }\n")+ fcx = walk_file("/tmp/x.ex", "elixir", b"defmodule X do\ndef f, do: 1\nend\n")assert isinstance(fcx, FileComplexity)assert fcx.functions == []@@ -162,18 +164,18 @@ def test_walk_of_an_unsupported_language_is_empty() -> None:def test_get_health_names_an_unscored_target_for_what_it_is(tmp_path) -> None:from repowise.server.mcp_server.tool_health.targets import _unresolved_targets- (tmp_path / "Big.php").write_text("<?php\n")+ (tmp_path / "Big.ex").write_text("defmodule Big do\nend\n")out = _unresolved_targets(- file_targets=["Big.php"],+ file_targets=["Big.ex"],module_targets=[],matched_modules=set(),resolved_paths=set(),excluded_paths=set(),unscored_paths=set(),repo_root=tmp_path,- unanalysed_paths={"Big.php"},+ unanalysed_paths={"Big.ex"},)- assert out == [{"target": "Big.php", "reason": "language_not_supported"}]+ assert out == [{"target": "Big.ex", "reason": "language_not_supported"}]def _refresh(language: str | None, stored_score: float | None):@@ -191,7 +193,7 @@ def _refresh(language: str | None, stored_score: float | None):def test_the_history_refresh_nulls_a_language_with_no_dialect() -> None:- assert _refresh("php", 10.0).score is None+ assert _refresh("elixir", 10.0).score is Nonedef test_a_file_with_no_graph_node_keeps_its_score() -> None:diff --git a/tests/unit/persistence/test_health_metric_nullable_rebuild.py b/tests/unit/persistence/test_health_metric_nullable_rebuild.pyindex e5ca29b43..55c6964d1 100644--- a/tests/unit/persistence/test_health_metric_nullable_rebuild.py+++ b/tests/unit/persistence/test_health_metric_nullable_rebuild.py@@ -57,11 +57,11 @@ async def test_a_not_null_store_is_rebuilt_and_keeps_its_rows(async_engine, asynassert not await _not_null(async_session, "score")assert not await _not_null(async_session, "max_ccn")- await save_health_metrics(async_session, repo.id, [_row("a.py", 7.5), _row("B.php", None)])+ await save_health_metrics(async_session, repo.id, [_row("a.py", 7.5), _row("B.ex", None)])await async_session.commit()by_path = {m.file_path: m for m in await get_health_metrics(async_session, repo.id)}assert by_path["a.py"].score == 7.5 and by_path["a.py"].max_ccn == 4- assert by_path["B.php"].score is None and by_path["B.php"].max_ccn is None+ assert by_path["B.ex"].score is None and by_path["B.ex"].max_ccn is None# Still one row per file: the unique constraint came back with the table.ddl_after = (await async_session.execute(@@ -92,18 +92,18 @@ async def _with_languages(session, repo_id: str, languages: dict[str, str]) -> Nasync def test_an_update_clears_a_stored_ten_for_a_language_with_no_dialect(async_session):- """A store written before this kept 10.0 / CCN 1 for every PHP file."""+ """A store written before this kept 10.0 / CCN 1 for every unanalysed file."""repo = await insert_repo(async_session)await save_health_metrics(async_session,repo.id,- [_row("Big.php", 10.0), _row("ok.py", 7.5), _row("orphan.py", 6.0)],+ [_row("Big.ex", 10.0), _row("ok.py", 7.5), _row("orphan.py", 6.0)],)# ``orphan.py`` has no graph node: no language, so it is left alone.- await _with_languages(async_session, repo.id, {"Big.php": "php", "ok.py": "python"})+ await _with_languages(async_session, repo.id, {"Big.ex": "elixir", "ok.py": "python"})assert await clear_unanalysed_scores(async_session, repo.id) == 1by_path = {m.file_path: m for m in await get_health_metrics(async_session, repo.id)}- assert by_path["Big.php"].score is None and by_path["Big.php"].max_ccn is None+ assert by_path["Big.ex"].score is None and by_path["Big.ex"].max_ccn is Noneassert by_path["ok.py"].score == 7.5assert by_path["orphan.py"].score == 6.0assert await clear_unanalysed_scores(async_session, repo.id) == 0@@ -115,7 +115,7 @@ async def test_the_badge_says_no_data_when_no_file_is_scored(async_session):repo = await insert_repo(async_session)# No rows at all is no data too: a repo of only data and config files has none.assert await _badge_average_health(async_session, repo.id) is None- await save_health_metrics(async_session, repo.id, [_row("Big.php", None)])+ await save_health_metrics(async_session, repo.id, [_row("Big.ex", None)])assert await _badge_average_health(async_session, repo.id) is None- await save_health_metrics(async_session, repo.id, [_row("Big.php", None), _row("a.py", 8.0)])+ await save_health_metrics(async_session, repo.id, [_row("Big.ex", None), _row("a.py", 8.0)])assert await _badge_average_health(async_session, repo.id) == 8.0