Skip to content

fix(quality): resolve final 4 CodeQL alerts#129

Merged
Prekzursil merged 1 commit into
mainfrom
fix/codeql-final-4
Apr 4, 2026
Merged

fix(quality): resolve final 4 CodeQL alerts#129
Prekzursil merged 1 commit into
mainfrom
fix/codeql-final-4

Conversation

@Prekzursil
Copy link
Copy Markdown
Owner

@Prekzursil Prekzursil commented Apr 4, 2026

Summary

  • Fix 4 remaining CodeQL alerts found after main-branch re-scan
  • cs/useless-upcast (2): Replace (object) cast with explicit new object[] array construction
  • cs/dereferenced-value-may-be-null (1): Remove redundant ! null-forgiving operator
  • cs/linq/missed-select (1): Flatten nested foreach with SelectMany

Test plan

  • Build passes (0 warnings, 0 errors)
  • CodeQL scan shows 0 open alerts after merge

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced Steam workshop content discovery to properly scan all configured library locations.
  • Tests

    • Refined test assertions and updated reflection-based test invocations for improved test reliability.

- cs/useless-upcast: replace (object) cast with explicit new object[]
  to prevent params array flattening without triggering upcast warning
- cs/dereferenced-value-may-be-null: remove redundant ! null-forgiving
  operator (FluentAssertions handles null assertion)
- cs/linq/missed-select: flatten nested foreach with SelectMany to
  eliminate intermediate variable mapping

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@devloai
Copy link
Copy Markdown

devloai Bot commented Apr 4, 2026

Unable to trigger custom agent "Code Reviewer". You have run out of credits 😔
Please upgrade your plan or buy additional credits from the subscription page.

@qodo-code-review
Copy link
Copy Markdown

Review Summary by Qodo

Resolve final 4 CodeQL alerts with code quality improvements

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Flatten nested foreach with SelectMany to eliminate intermediate variable
• Replace (object) cast with explicit new object[] array construction
• Remove redundant null-forgiving operator in assertion chain
Diagram
flowchart LR
  A["CodeQL Alerts"] --> B["Nested Loop Flattening"]
  A --> C["Useless Upcast Fix"]
  A --> D["Null-Forgiving Operator Removal"]
  B --> E["SelectMany Refactor"]
  C --> F["Explicit Array Construction"]
  D --> G["Cleaner Assertions"]
Loading

Grey Divider

File Changes

1. src/SwfocTrainer.Runtime/Services/ModDependencyValidator.cs 🐞 Bug fix +14/-17

Flatten nested foreach with SelectMany

• Replaced nested foreach loops with SelectMany to flatten drive discovery logic
• Eliminated intermediate steamCandidates array variable
• Improved code readability by reducing nesting depth
• Maintains same functionality while resolving cs/linq/missed-select alert

src/SwfocTrainer.Runtime/Services/ModDependencyValidator.cs


2. tests/SwfocTrainer.Tests/App/ProgramServiceRegistrationTests.cs 🐞 Bug fix +1/-1

Remove redundant null-forgiving operator

• Removed redundant null-forgiving operator (!) from remoteManifestUrl!
• FluentAssertions NotBeNull() already handles null assertion
• Simplifies code without changing behavior

tests/SwfocTrainer.Tests/App/ProgramServiceRegistrationTests.cs


3. tests/SwfocTrainer.Tests/Profiles/ModOnboardingCalibrationCoverageSweepTests.cs 🐞 Bug fix +2/-2

Replace object cast with explicit array construction

• Replaced (object) cast with explicit new object[] { samples } array construction
• Prevents params array flattening without triggering upcast warning
• Applied to both InferWorkshopIds and InferPathHints method calls
• Resolves cs/useless-upcast CodeQL alerts

tests/SwfocTrainer.Tests/Profiles/ModOnboardingCalibrationCoverageSweepTests.cs


Grey Divider

Qodo Logo

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 4, 2026

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 66619296-379d-4787-9686-54a2f88865a6

📥 Commits

Reviewing files that changed from the base of the PR and between 74dd4d1 and 74175a3.

📒 Files selected for processing (3)
  • src/SwfocTrainer.Runtime/Services/ModDependencyValidator.cs
  • tests/SwfocTrainer.Tests/App/ProgramServiceRegistrationTests.cs
  • tests/SwfocTrainer.Tests/Profiles/ModOnboardingCalibrationCoverageSweepTests.cs

📝 Walkthrough

Walkthrough

Refactoring of the workshop root discovery mechanism that restructures enumeration logic using SelectMany and reorganizes library folder parsing, alongside test updates for assertion syntax and reflection-based method invocation parameters.

Changes

Cohort / File(s) Summary
Workshop Discovery Implementation
src/SwfocTrainer.Runtime/Services/ModDependencyValidator.cs
Refactored DiscoverWorkshopRoots() to use SelectMany for flattening candidate Steam root paths and restructured the loop logic. Moved libraryfolders.vdf parsing outside conditional logic, applying it per-candidate Steam root iteration.
Test Assertion & Reflection Updates
tests/SwfocTrainer.Tests/App/ProgramServiceRegistrationTests.cs, tests/SwfocTrainer.Tests/Profiles/ModOnboardingCalibrationCoverageSweepTests.cs
Removed null-forgiving operator from test assertion; updated reflection-based method invocations to pass samples via new object[] { samples } instead of (object) cast.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Hops through code with glee,
Steam roots now enumerate free,
SelectMany flattens the way,
Tests assert without delay,
Workshop discovery—hopping spree! 🌳✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete against the template; it lacks required sections including Risk assessment, Affected Profiles, Reliability Evidence, Rollback steps, and Scope Guard checkboxes. Complete the description by adding Risk level, Affected Profiles checkboxes, Reliability Evidence section with test results, Rollback procedure, and Scope Guard checklist items to meet repository requirements.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title concisely and accurately describes the main objective: resolving CodeQL alerts through code quality improvements.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/codeql-final-4

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-code-review
Copy link
Copy Markdown

qodo-code-review Bot commented Apr 4, 2026

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@deepsource-io
Copy link
Copy Markdown

deepsource-io Bot commented Apr 4, 2026

DeepSource Code Review

We reviewed changes in 74dd4d1...74175a3 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Terraform Apr 4, 2026 7:05a.m. Review ↗
SQL Apr 4, 2026 7:05a.m. Review ↗
Rust Apr 4, 2026 7:05a.m. Review ↗
Shell Apr 4, 2026 7:05a.m. Review ↗
Ruby Apr 4, 2026 7:05a.m. Review ↗
PHP Apr 4, 2026 7:05a.m. Review ↗
Kotlin Apr 4, 2026 7:05a.m. Review ↗
Swift Apr 4, 2026 7:05a.m. Review ↗
Scala Apr 4, 2026 7:05a.m. Review ↗
Python Apr 4, 2026 7:05a.m. Review ↗
JavaScript Apr 4, 2026 7:05a.m. Review ↗
Java Apr 4, 2026 7:05a.m. Review ↗
Go Apr 4, 2026 7:05a.m. Review ↗
Docker Apr 4, 2026 7:05a.m. Review ↗
C & C++ Apr 4, 2026 7:05a.m. Review ↗
Ansible Apr 4, 2026 7:05a.m. Review ↗

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Apr 4, 2026

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0 (≤ 10 complexity)
Duplication 0 (≤ 0 duplication)

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@Prekzursil Prekzursil merged commit 7330431 into main Apr 4, 2026
44 of 53 checks passed
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.

1 participant