Skip to content

test: add VS Code integration test suite for RustMetricsAnalyzer#328

Open
github-actions[bot] wants to merge 2 commits into
mainfrom
repo-assist/test-rust-analyzer-20260521-9d2395f6a4afafe2
Open

test: add VS Code integration test suite for RustMetricsAnalyzer#328
github-actions[bot] wants to merge 2 commits into
mainfrom
repo-assist/test-rust-analyzer-20260521-9d2395f6a4afafe2

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Adds src/test/metricsAnalyzer/languages/rustAnalyzer.test.ts — the VS Code integration test suite for RustMetricsAnalyzer.

Every other language analyzer already has a corresponding test file in this directory (C#, Go, Java, JavaScript, jsLike, Python, TSX, TypeScript). This PR completes the set by adding the missing Rust counterpart.

Test Coverage

The new test suite covers:

Suite Cases
Basic Function Analysis simple fn, if expression, multiple fns, empty source, no functions
Control Flow for, while, loop, match, nested, else-if clause
Boolean Operators &&, ||, chained operators
Impl Methods qualified names (Struct::method), complexity, multiple methods
Closures top-level (no increment), nested (increment)
Position Information startLine accuracy
Static Factory Method RustMetricsAnalyzer.analyzeFile()

Test Status

  • npm run compile — passed, no TypeScript errors
  • npm run lint — passed, no ESLint issues
  • npm run test:unit — 100/100 passing (Rust unit tests already in unit.test.ts)
  • i️ VS Code integration tests (npm test) require VS Code download — not runnable in sandboxed CI environment; infrastructure-only limitation

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.

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@79c99dfd73f3b7ad8ab2b0f4944838018dbe4736

Add rustAnalyzer.test.ts to src/test/metricsAnalyzer/languages/ covering:
- Basic function analysis (simple fn, if expression, multiple fns, empty/no-fn)
- Control flow: for, while, loop, match, nested, else-if
- Boolean operators: &&, ||, chained
- Impl methods: qualified names, complexity, multiple methods
- Closures: top-level (no increment), nested
- Position information: startLine accuracy
- Static factory method: analyzeFile()

All other language analyzers already have an equivalent test file;
this completes the set.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@askpt askpt changed the title [repo-assist] test: add VS Code integration test suite for RustMetricsAnalyzer test: add VS Code integration test suite for RustMetricsAnalyzer May 21, 2026
@askpt askpt marked this pull request as ready for review May 21, 2026 16:03
@askpt askpt self-requested a review as a code owner May 21, 2026 16:03
Copilot AI review requested due to automatic review settings May 21, 2026 16:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a VS Code integration test file for the existing RustMetricsAnalyzer, aligning Rust with the other language analyzers’ integration test coverage under src/test/metricsAnalyzer/languages/.

Changes:

  • Added rustAnalyzer.test.ts integration tests for Rust function detection, complexity increments, qualified impl method names, and position reporting.
  • Included scenarios for control-flow constructs (if/else, loops, match), boolean operators, and closures.
  • Added a static factory method test for RustMetricsAnalyzer.analyzeFile().
Comments suppressed due to low confidence (3)

src/test/metricsAnalyzer/languages/rustAnalyzer.test.ts:57

  • subtract uses an if … else … expression, and the Rust analyzer counts the else_clause as +1 as well. The expected complexity of this function should be 2 (if + else), not 1.
      assert.strictEqual(results.length, 2);
      assert.strictEqual(results[0].name, "add");
      assert.strictEqual(results[0].complexity, 0);
      assert.strictEqual(results[1].name, "subtract");
      assert.strictEqual(results[1].complexity, 1);
    });

src/test/metricsAnalyzer/languages/rustAnalyzer.test.ts:161

  • This if / else if / else chain should include an else clause increment as well. The Rust analyzer reports reasons ["if expression", "else if clause", "else clause"] with total complexity 3 for this pattern, so expecting 2 here will fail.
      // if(1) + else if(1) = 2
      const results = analyzer.analyzeFunctions(sourceCode);
      assert.strictEqual(results[0].complexity, 2);
      const reasons = results[0].details.map((d) => d.reason);
      assert.ok(reasons.includes("if expression"));
      assert.ok(reasons.includes("else if clause"));
    });

src/test/metricsAnalyzer/languages/rustAnalyzer.test.ts:288

  • This test claims to verify nested-closure counting, but the closure (|x| x * 2) is after the if block, so it’s at nesting level 0 and should not add complexity. As written, the assertion can pass even if nested closures are never counted; restructure the sample so the closure is actually inside a nested context (e.g., within the if body) and assert a closure (nested) detail/increment.
    test("should count nested closure", () => {
      const sourceCode = `
fn process(items: &[i32]) -> i32 {
    if items.is_empty() {
        return 0;
    }
    items.iter().map(|x| x * 2).sum()
}
`;
      // if(1) + closure nested inside if context → complexity >= 1
      const results = analyzer.analyzeFunctions(sourceCode);
      assert.ok(results[0].complexity >= 1);
    });

Comment thread src/test/metricsAnalyzer/languages/rustAnalyzer.test.ts
Copilot finished work on behalf of askpt May 21, 2026 16:13
@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.23%. Comparing base (6e2ba04) to head (fd38346).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #328   +/-   ##
=======================================
  Coverage   76.23%   76.23%           
=======================================
  Files          13       13           
  Lines        3981     3981           
  Branches      428      428           
=======================================
  Hits         3035     3035           
  Misses        944      944           
  Partials        2        2           

☔ View full report in Codecov by Sentry.
📢 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.

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.

2 participants