Skip to content

Fix SonarQube and CodeQL code quality issues#156

Merged
Malcolmnixon merged 5 commits intomainfrom
copilot/fix-sonarqube-code-quality-issues
Apr 11, 2026
Merged

Fix SonarQube and CodeQL code quality issues#156
Malcolmnixon merged 5 commits intomainfrom
copilot/fix-sonarqube-code-quality-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 11, 2026

Pull Request

Description

Address static analysis findings from SonarQube and CodeQL across source and test code. All changes are behavior-preserving.

  • IDE0028 — Simplify collection initializers (new List<T>()[], new HashSet<T>().ToHashSet()) across 11 files
  • CA2263 — Use generic Assert.IsInstanceOfType<T>() in VersionTests (13 call sites)
  • S1192 — Extract repeated "- N/A" literal to NoItemsPlaceholder constant in BuildInformation

Example:

// Before
var rules = new List<RuleConfig> { ... };
Assert.IsInstanceOfType(simple, typeof(VersionComparable));

// After
List<RuleConfig> rules = [ ... ];
Assert.IsInstanceOfType<VersionComparable>(simple);

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code quality improvement

Related Issues

Pre-Submission Checklist

Before submitting this pull request, ensure you have completed the following:

Build and Test

  • Code builds successfully: dotnet build --configuration Release
  • All tests pass: dotnet test --configuration Release
  • Self-validation tests pass:
    dotnet run --project src/DemaConsulting.BuildMark --configuration Release --framework net10.0
    --no-build -- --validate
  • Code produces zero warnings

Code Quality

  • Code formatting is correct: dotnet format --verify-no-changes
  • New code has appropriate XML documentation comments
  • Static analyzer warnings have been addressed

Quality Checks

Please run the following checks before submitting:

  • All linters pass: ./lint.sh (Unix/macOS) or cmd /c lint.bat / ./lint.bat (Windows)

Testing

  • Added unit tests for new functionality
  • Updated existing tests if behavior changed
  • All tests follow the AAA (Arrange, Act, Assert) pattern
  • Test coverage is maintained or improved

Documentation

  • Updated README.md (if applicable)
  • Updated ARCHITECTURE.md (if applicable)
  • Added code examples for new features (if applicable)
  • Updated requirements.yaml (if applicable)

Additional Notes

467 tests pass across net8.0, net9.0, and net10.0. CodeQL scan: 0 alerts.

Copilot AI and others added 5 commits April 11, 2026 15:50
Agent-Logs-Url: https://github.com/demaconsulting/BuildMark/sessions/1faac23d-63db-4f04-9f85-cee6c1de684c

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
…S1192)

Agent-Logs-Url: https://github.com/demaconsulting/BuildMark/sessions/1faac23d-63db-4f04-9f85-cee6c1de684c

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
@Malcolmnixon Malcolmnixon marked this pull request as ready for review April 11, 2026 16:10
Copilot AI review requested due to automatic review settings April 11, 2026 16:10
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

This PR addresses static analysis findings (SonarQube/CodeQL/.NET analyzers) with behavior-preserving refactors across the BuildMark tool and its test suite.

Changes:

  • Modernize collection initialization patterns using C# collection expressions ([]) and ToHashSet(...).
  • Update MSTest assertions to use the generic Assert.IsInstanceOfType<T>() overloads.
  • Centralize the repeated Markdown empty-section placeholder ("- N/A") into a single constant in BuildInformation.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/DemaConsulting.BuildMark.Tests/Version/VersionTests.cs Switches to generic Assert.IsInstanceOfType<T>() overloads.
test/DemaConsulting.BuildMark.Tests/RepoConnectors/RepoConnectorsTests.cs Uses collection expressions for test data setup lists.
test/DemaConsulting.BuildMark.Tests/RepoConnectors/RepoConnectorBaseTests.cs Uses collection expressions for rules/sections/items test setup.
test/DemaConsulting.BuildMark.Tests/RepoConnectors/Mock/MockRepoConnectorTests.cs Uses collection expressions for rules/sections setup in mock connector tests.
test/DemaConsulting.BuildMark.Tests/RepoConnectors/GitHub/GitHubRepoConnectorTests.cs Uses collection expressions for rules/sections setup in GitHub connector tests.
test/DemaConsulting.BuildMark.Tests/RepoConnectors/AzureDevOps/AzureDevOpsRepoConnectorTests.cs Uses collection expressions for rules/sections setup in Azure DevOps connector tests.
test/DemaConsulting.BuildMark.Tests/IntegrationTests.cs Uses collection expressions for temporary item buckets in integration test scaffolding.
test/DemaConsulting.BuildMark.Tests/BuildNotes/BuildInformationTests.cs Uses collection expressions for routed sections test setup.
src/DemaConsulting.BuildMark/SelfTest/Validation.cs Uses collection expressions for self-test connector configuration and argument building.
src/DemaConsulting.BuildMark/RepoConnectors/ItemRouter.cs Simplifies bucket initialization with collection expressions.
src/DemaConsulting.BuildMark/RepoConnectors/GitHub/GitHubRepoConnector.cs Replaces HashSet constructors with ToHashSet() for lookup data construction.
src/DemaConsulting.BuildMark/RepoConnectors/AzureDevOps/AzureDevOpsRepoConnector.cs Uses ToHashSet(StringComparer.Ordinal) for commit hash set construction.
src/DemaConsulting.BuildMark/Configuration/BuildMarkConfigReader.cs Uses collection expression for initializing the issues list.
src/DemaConsulting.BuildMark/BuildNotes/BuildInformation.cs Extracts repeated "- N/A" into a single NoItemsPlaceholder constant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Malcolmnixon Malcolmnixon merged commit 30b630c into main Apr 11, 2026
19 checks passed
@Malcolmnixon Malcolmnixon deleted the copilot/fix-sonarqube-code-quality-issues branch April 11, 2026 16:36
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.

3 participants