Repository navigation
TCE-1645 fix stack overflow issue - #278
DMarinhoCodacy wants to merge 2 commits into
Conversation
Up to standards ✅🟢 Issues
|
| Category | Results |
|---|---|
| CodeStyle | 2 minor |
🟢 Metrics 4 complexity
Metric Results Complexity 4
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
The duplicate local declaration prevents the analyzer from compiling, so this must be fixed before merging.
Codacy also found:
- 2 code-style findings in
src/Analyzer/CodeAnalyzer.csrecommending braces around new control-flow bodies.
Test suggestions
- Analyze a deeply nested C# file and verify it is skipped with the expected result instead of overflowing the stack.
- Analyze a file at or below the depth threshold and verify normal diagnostics are produced.
- Verify concurrent file analysis honors cancellation.
- Verify the runtime configuration provides the intended enlarged thread stack.
- Verify iterative syntax-tree depth calculation handles deep trees without recursion.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Analyze a deeply nested C# file and verify it is skipped with the expected result instead of overflowing the stack.
2. Analyze a file at or below the depth threshold and verify normal diagnostics are produced.
3. Verify concurrent file analysis honors cancellation.
4. Verify the runtime configuration provides the intended enlarged thread stack.
5. Verify iterative syntax-tree depth calculation handles deep trees without recursion.
TIP Add review instructions in .codacy/instructions/review.md, or an AGENTS.md, so the reviewer knows your conventions.
TIP How was this review? Give us feedback
| var max = 0; | ||
| var stack = new Stack<(SyntaxNode Node, int Depth)>(); | ||
| stack.Push((root, 1)); | ||
| while (stack.Count > 0) |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Cancellation can be delayed while large syntax trees are fully traversed, including after their depth already exceeds the limit. Consider checking the cancellation token during traversal and returning as soon as the limit is exceeded.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
| var compilation = await solution.Projects.First().GetCompilationAsync(); | ||
|
|
||
| var root = await compilation.SyntaxTrees.First().GetRootAsync(cancellationToken); | ||
| if (GetMaxDepth(root) > MaxSyntaxDepth) |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Valid files deeper than 1,000 syntax nodes receive no diagnostics, even when the analyzers could process them with the enlarged stack. Consider a larger-stack fallback or a configurable limit instead of unconditionally skipping these files.
TIP React 👍 if this review is right, or reply with what's wrong and how it could be better to help improve the reviewer.
No description provided.