Skip to content

style: resolve the two open SonarQube issues - #183

Merged
HandyS11 merged 1 commit into
developfrom
fix/sonar-ide0270-ide0028
Aug 7, 2026
Merged

style: resolve the two open SonarQube issues#183
HandyS11 merged 1 commit into
developfrom
fix/sonar-ide0270-ide0028

Conversation

@HandyS11

@HandyS11 HandyS11 commented Aug 7, 2026

Copy link
Copy Markdown
Owner

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) throw guard into a ?? throw on the await. The comment explaining why every failure in this method throws McpException (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 its params constructor.

Worth noting: the obvious fix — a collection expression => [...] — does clear IDE0028 and compiles, but Roslyn lowers it to new TheoryData<Exception>([]) followed by Add calls, and that empty array trips CA1825 (Avoid unnecessary zero-length array allocations), which is an error under TreatWarningsAsErrors. The params constructor avoids both.

Verification

  • dtk dotnet build ProjGraph.slnx — clean, 0 warnings, 16 projects
  • dtk dotnet test ProjGraph.slnx — 1122 passed, 0 failed
  • dtk dotnet format ProjGraph.slnx --verify-no-changes — nothing to format

No behaviour change; both edits are style-only.

🤖 Generated with Claude Code

- 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>
Copilot AI lite review requested due to automatic review settings August 7, 2026 19:54

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

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 the params constructor 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.

@HandyS11
HandyS11 merged commit d02e6a8 into develop Aug 7, 2026
7 checks passed
@HandyS11
HandyS11 deleted the fix/sonar-ide0270-ide0028 branch August 7, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants