test: cover C# preprocessor ERROR-node and malformed-declaration reason branches - #539
Merged
askpt merged 3 commits intoAug 13, 2026
Conversation
…on branches Adds tests for previously-untested branches in getComplexityReasonFromErrorNode (if/while/for/foreach/logical-operator/ternary/try) and getComplexityReasonFromMalformedDeclaration (ternary/logical-operator), raising csharpAnalyzer.ts branch coverage from 78.32% to 87.33%. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
askpt
marked this pull request as ready for review
August 13, 2026 07:01
Contributor
There was a problem hiding this comment.
Pull request overview
Adds C# analyzer tests for complexity reasons in preprocessor-fragmented syntax.
Changes:
- Covers seven
ERROR-node reason branches. - Adds malformed-declaration ternary and logical-operator tests.
Suppressed comments (1)
src/unit/unit.test.ts:4105
- This is already covered by the logical-operator malformed-declaration test at
src/unit/unit.test.ts:3473-3497; both use the same preprocessor structure and assert the same reason. Remove this duplicate so the suite does not maintain two equivalent regression cases.
it("should detect a logical operator in a malformed preprocessor declaration", () => {
// Covers the logical-operator branch in getComplexityReasonFromMalformedDeclaration.
const sourceCode = `
public class Foo {
public void Baz()
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…eclaration tests Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
…20260813-a9904f22f4042e8c
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #539 +/- ##
==========================================
+ Coverage 81.85% 82.80% +0.95%
==========================================
Files 13 13
Lines 4386 4386
Branches 450 455 +5
==========================================
+ Hits 3590 3632 +42
+ Misses 795 753 -42
Partials 1 1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
askpt
enabled auto-merge (squash)
August 13, 2026 07:17
askpt
deleted the
repo-assist/test-csharp-error-node-branches-20260813-a9904f22f4042e8c
branch
August 13, 2026 07:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This pull request was created by Repo Assist, an automated AI assistant.
Summary
Adds unit tests covering the untested reason branches in
csharpAnalyzer.ts:getComplexityReasonFromErrorNode:if,while,for,foreach, logical-operator, ternary-operator, andtrybranches (only thecatchbranch had a test previously).getComplexityReasonFromMalformedDeclaration: ternary-operator and logical-operator branches (only the final no-match fallback had a test previously).These functions handle heuristic detection of complexity patterns inside
ERROR/ malformed-declaration nodes that tree-sitter emits when#if/#elsepreprocessor directives split a C# method body mid-statement. Each branch maps recognised text patterns to a human-readable complexity reason string; most were exercised only indirectly or not at all.Rationale
csharpAnalyzer.tsbranch coverage was 78.32%, the lowest of all language analyzers.Test Status
Coverage improved:
csharpAnalyzer.tsbranch coverage 78.32% → 87.33% (statements 92.72% → 95.49%). Remaining uncovered lines (262-263, 340-344, some fragments of 610-628, 737-738, 752-754, 827) are either defensive fallbacks or complex multi-condition regex branches left for a future pass, per minimal-scope guidance.Trade-offs
None — pure test addition, no behavior change.
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
releaseassets.githubusercontent.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run