From e3e2489931f638de8539c552d7c03d6fbb60893c Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 10 Aug 2026 03:13:32 +0000 Subject: [PATCH] test: add C# chained &&/|| deduplication branch coverage Adds tests for C# logical operator chain deduplication, mirroring the existing JS/Go/Python/Rust tests. This covers the parent-chain short-circuit branch (return 0 for inner nodes of a same-operator chain) in csharpAnalyzer.ts's getComplexityIncrement, which was previously untested for the C# analyzer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/unit/unit.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/unit/unit.test.ts b/src/unit/unit.test.ts index f724c85..4a8f578 100644 --- a/src/unit/unit.test.ts +++ b/src/unit/unit.test.ts @@ -3835,6 +3835,24 @@ class A { assert.strictEqual(results.length, 1, "should analyze exactly one Rust function"); assert.strictEqual(results[0].complexity, 2, "Rust a&&b||c should count as 2"); }); + + it("C#: chained && counts once, not per pair", () => { + const results = MetricsAnalyzerFactory.analyzeFile( + "class Foo { bool Bar(bool a, bool b, bool c) { return a && b && c; } }", + "csharp" + ); + assert.strictEqual(results.length, 1, "should analyze exactly one C# method"); + assert.strictEqual(results[0].complexity, 1, "C# chained && should count as 1"); + }); + + it("C#: mixed && and || counts each sequence separately", () => { + const results = MetricsAnalyzerFactory.analyzeFile( + "class Foo { bool Bar(bool a, bool b, bool c) { return a && b || c; } }", + "csharp" + ); + assert.strictEqual(results.length, 1, "should analyze exactly one C# method"); + assert.strictEqual(results[0].complexity, 2, "C# a&&b||c should count as 2"); + }); }); // ──────────────────────────────────────────────────────────────────────────