Skip to content

Fix CodeQL warnings: LINQ filtering, mapping, and resource disposal#71

Merged
Malcolmnixon merged 2 commits intomainfrom
copilot/fix-codeql-issues
Jan 27, 2026
Merged

Fix CodeQL warnings: LINQ filtering, mapping, and resource disposal#71
Malcolmnixon merged 2 commits intomainfrom
copilot/fix-codeql-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 27, 2026

Pull Request

Description

Addresses three CodeQL warnings by refactoring implicit LINQ operations to explicit ones and ensuring proper resource disposal.

Changes:

  • RunResults.cs: Replaced implicit filtering (continue statement) with explicit .Where() clause

    // Before: foreach (var line in Lines) { if (!context.Verbose && line.Type == RunLineType.Text) continue; ... }
    // After: foreach (var line in Lines.Where(l => context.Verbose || l.Type != RunLineType.Text))
  • Simulator.cs: Replaced nested foreach loops with .SelectMany() and .Select() for path/file combination

    // Before: nested foreach with immediate mapping and File.Exists check
    // After: searchPaths.SelectMany(p => searchFiles.Select(f => Path.Combine(p, f))).FirstOrDefault(File.Exists)
  • RunProgram.cs: Added using declaration for Process disposal

    // Before: var p = new Process { StartInfo = startInfo };
    // After: using var p = new Process { StartInfo = startInfo };

Type of Change

  • Code quality improvement

Pre-Submission Checklist

Build and Test

  • Code builds successfully: dotnet build --configuration Release
  • All tests pass: dotnet test --configuration Release
  • 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:

  • Spell checker passes: cspell "**/*.{md,cs}"
  • Markdown linter passes: markdownlint "**/*.md"
  • YAML linter passes: yamllint '**/*.{yml,yaml}'

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

All 85 existing tests pass. CodeQL analysis reports 0 alerts.

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature]: CodeQL Cleanup</issue_title>
<issue_description>### Problem Statement

CodeQL is reporting a few issues

Proposed Solution

Fix the following issues:

src/DEMAConsulting.VHDLTest/Run/RunResults.cs(48): warning [cs/linq/missed-where] This foreach loop [implicitly filters its target sequence](1) - consider filtering the sequence explicitly using '.Where(...)'.  
src/DEMAConsulting.VHDLTest/Simulators/Simulator.cs(105): warning [cs/linq/missed-select] This foreach loop immediately [maps its iteration variable to another variable](1) - consider mapping the sequence explicitly using '.Select(...)'.  
src/DEMAConsulting.VHDLTest/Run/RunProgram.cs(57): warning [cs/local-not-disposed] Disposable 'Process' is created but not disposed.  

Alternatives Considered

No response

Usage Examples

Benefits

Improved code quality

Priority

Medium - Would improve my workflow

Willingness to Contribute

Yes, I can submit a pull request

Additional Context

No response

Checklist

  • I have searched existing issues to ensure this is not a duplicate
  • I have provided a clear description of the feature
  • I have explained why this feature would be useful</issue_description>

Comments on the Issue (you are @copilot in this section)


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

… disposal

Co-authored-by: Malcolmnixon <1863707+Malcolmnixon@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CodeQL issues in VHDLTest project Fix CodeQL warnings: LINQ filtering, mapping, and resource disposal Jan 27, 2026
Copilot AI requested a review from Malcolmnixon January 27, 2026 12:31
@Malcolmnixon Malcolmnixon marked this pull request as ready for review January 27, 2026 13:20
@Malcolmnixon Malcolmnixon merged commit 4d7882f into main Jan 27, 2026
19 checks passed
@Malcolmnixon Malcolmnixon deleted the copilot/fix-codeql-issues branch January 27, 2026 13:20
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.

[Feature]: CodeQL Cleanup

2 participants