Skip to content

test: cover C# preprocessor ERROR-node and malformed-declaration reason branches - #539

Merged
askpt merged 3 commits into
mainfrom
repo-assist/test-csharp-error-node-branches-20260813-a9904f22f4042e8c
Aug 13, 2026
Merged

test: cover C# preprocessor ERROR-node and malformed-declaration reason branches#539
askpt merged 3 commits into
mainfrom
repo-assist/test-csharp-error-node-branches-20260813-a9904f22f4042e8c

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 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, and try branches (only the catch branch 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/#else preprocessor 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

  • Genuine, low-risk coverage gap: csharpAnalyzer.ts branch coverage was 78.32%, the lowest of all language analyzers.
  • Test-only addition — zero production code changes, zero behavioral risk.
  • Locks in the existing (correct) fallback behavior with regression tests.

Test Status

npm run compile   ✅ (0 errors)
npm run lint      ✅ (0 warnings)
npm run test:unit ✅ 226 passing, 0 failing (was 217)

Coverage improved: csharpAnalyzer.ts branch 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.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "releaseassets.githubusercontent.com"

See Network Configuration for more information.

Generated by 🌈 Repo Assist, see workflow run. Learn more.
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@42c2ab5b4e4c9273534c39259b2e0df7f20f07e9

…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 askpt changed the title [repo-assist] test: cover C# preprocessor ERROR-node and malformed-declaration reason branches test: cover C# preprocessor ERROR-node and malformed-declaration reason branches Aug 13, 2026
@askpt
askpt marked this pull request as ready for review August 13, 2026 07:01
@askpt
askpt self-requested a review as a code owner August 13, 2026 07:01
Copilot AI balanced review requested due to automatic review settings August 13, 2026 07:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/unit/unit.test.ts Outdated
Comment thread src/unit/unit.test.ts Outdated
…eclaration tests

Co-authored-by: askpt <2493377+askpt@users.noreply.github.com>
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.80%. Comparing base (e6930fc) to head (be24079).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@askpt
askpt enabled auto-merge (squash) August 13, 2026 07:17
@askpt
askpt merged commit 6ea8fc2 into main Aug 13, 2026
10 checks passed
@askpt
askpt deleted the repo-assist/test-csharp-error-node-branches-20260813-a9904f22f4042e8c branch August 13, 2026 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants