Skip to content

Apply SonarQube code quality improvements#50

Merged
Malcolmnixon merged 3 commits intomainfrom
copilot/cleanup-sonarqube-issues
Jan 10, 2026
Merged

Apply SonarQube code quality improvements#50
Malcolmnixon merged 3 commits intomainfrom
copilot/cleanup-sonarqube-issues

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

SonarQube Cleanup Improvements

  • Replace collection initialization new() with {} in source files
    • TraceMatrix.cs: _testResults field
    • Requirement.cs: Tests and Children properties
    • Context.cs: RequirementsFiles and TestFiles properties
    • Requirements.cs: _includedFiles and _allRequirements fields
    • Section.cs: Requirements and Sections properties
    • TraceMatrix.cs: List initialization in TryGetValue block
  • Use ArgumentNullException.ThrowIfNull instead of manual null checks
    • TraceMatrix.cs: Constructor null check for requirements parameter
  • Mark CollectAllTests method as static in TraceMatrix.cs
  • Replace Dictionary ContainsKey + indexer with TryGetValue in TraceMatrix.cs
  • Replace StringAssert.Contains with Assert.Contains in test files
    • RequirementsExportTests.cs
    • RequirementsReadTests.cs
    • TraceMatrixReadTests.cs
    • TraceMatrixExportTests.cs
    • TraceMatrixTests.cs
    • ContextTests.cs
    • ProgramTests.cs
    • RequirementsParsingTests.cs
  • Replace constant array argument with static readonly field in TraceMatrixExportTests.cs

All changes complete. Build succeeded with 0 warnings and 0 errors. All 127 tests passed.

Original prompt

Please perform additional cleanups identified by SonarQube - specifically things like:

  • Collection Initialization can be simplified - recommending "{}" over "new()"
  • Use of ArgumentNullException.ThrowIfNull
  • Member 'CollectAllTests' does not access instance data and can be marked as static
  • Prefer a 'TryGetValue' call over a Dictionary indexer access guarded by a 'ContainsKey' check to avoid double lookup
  • Use 'Assert.Contains' instead of 'StringAssert.Contains'
  • Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

- Replace collection initialization new() with {} in all source files
- Use ArgumentNullException.ThrowIfNull in TraceMatrix constructor
- Mark CollectAllTests method as static in TraceMatrix
- Replace Dictionary ContainsKey+indexer with TryGetValue in TraceMatrix
- Replace StringAssert.Contains with Assert.Contains in all test files
- Replace constant array argument with static readonly field in TraceMatrixExportTests

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix SonarQube identified cleanups Apply SonarQube code quality improvements Jan 10, 2026
Copilot AI requested a review from Malcolmnixon January 10, 2026 06:56
Apply collection expression [] instead of new List<string>() for consistency

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Copilot AI requested a review from Malcolmnixon January 10, 2026 07:03
@Malcolmnixon Malcolmnixon marked this pull request as ready for review January 10, 2026 07:06
@Malcolmnixon Malcolmnixon merged commit 6756242 into main Jan 10, 2026
13 checks passed
@Malcolmnixon Malcolmnixon deleted the copilot/cleanup-sonarqube-issues branch January 10, 2026 07:11
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