style: resolve the two open SonarQube issues - #183
Merged
Conversation
- WorkspaceRootService (IDE0270): collapse the `is null` guard into a `?? throw` on the await, folding the McpException rationale comment into the single block above the assignment. - ClassDiagramCoverageTests (IDE0028): build the TheoryData via its params constructor instead of a collection initializer. A collection expression also clears IDE0028 but lowers through `new TheoryData<Exception>([])` plus Add calls, which trips CA1825 (zero-length array allocation). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses the last two open SonarQube INFO-level style issues by simplifying a null-guard in the MCP workspace root resolver and simplifying a unit test data initializer, without changing behavior.
Changes:
- Simplified the workspace-roots null guard to
await ... ?? throw new McpException(...)in the MCP server’s path resolution flow. - Simplified
TheoryData<Exception>initialization in unit tests by using theparamsconstructor to avoid IDE0028 (and avoid CA1825 pitfalls with collection expressions).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/ProjGraph.Mcp/WorkspaceRootService.cs |
Refactors workspace-roots retrieval null-check into a ?? throw while keeping client-facing McpException guidance intact. |
tests/ProjGraph.Tests.Unit.ClassDiagram/ClassDiagramCoverageTests.cs |
Simplifies TheoryData<Exception> initialization for the MemberData source in coverage tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Clears the two remaining OPEN issues on the SonarQube project (both
INFO,CONSISTENT/ conventional).src/ProjGraph.Mcp/WorkspaceRootService.cs:57— IDE0270 "Null check can be simplified"Collapsed the
if (roots is null) throwguard into a?? throwon theawait. The comment explaining why every failure in this method throwsMcpException(the SDK swallows other exception types behind a generic message) moved up to join the block above the assignment, so the rationale still sits next to the first throw.tests/ProjGraph.Tests.Unit.ClassDiagram/ClassDiagramCoverageTests.cs:62— IDE0028 "Collection initialization can be simplified"Switched
TheoryData<Exception>to itsparamsconstructor.Worth noting: the obvious fix — a collection expression
=> [...]— does clear IDE0028 and compiles, but Roslyn lowers it tonew TheoryData<Exception>([])followed byAddcalls, and that empty array trips CA1825 (Avoid unnecessary zero-length array allocations), which is an error underTreatWarningsAsErrors. Theparamsconstructor avoids both.Verification
dtk dotnet build ProjGraph.slnx— clean, 0 warnings, 16 projectsdtk dotnet test ProjGraph.slnx— 1122 passed, 0 faileddtk dotnet format ProjGraph.slnx --verify-no-changes— nothing to formatNo behaviour change; both edits are style-only.
🤖 Generated with Claude Code