chore(codeql): readonly fields and TryGetValue cleanups#224
Conversation
Bundle ReportBundle size has no change ✅ |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #224 +/- ##
=======================================
Coverage 44.51% 44.51%
=======================================
Files 895 895
Lines 51760 51760
Branches 4827 4827
=======================================
Hits 23041 23041
Misses 28149 28149
Partials 570 570
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
Pull request overview
This PR applies small, behavior-preserving CodeQL cleanups across the web app and test suite by (1) marking single-assignment static fields as readonly and (2) replacing ContainsKey + indexer patterns with TryGetValue to avoid double lookups.
Changes:
- Marked static
HttpClientand SQLite test fixtures asreadonlywhere they are never reassigned. - Replaced
ContainsKey+ indexer withTryGetValueinRotationsControllerand an emergency-contact unit test to avoid redundant dictionary lookups.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| web/Areas/Directory/Services/VMACSService.cs | Marks the shared static HttpClient as readonly. |
| web/Areas/ClinicalScheduler/Controllers/RotationsController.cs | Uses TryGetValue for the recent-clinicians lookup to avoid double dictionary access. |
| test/Students/EmergencyContactControllerTests.cs | Uses TryGetValue for a single-lookup assertion on validation errors. |
| test/RAPS/RolesTests.cs | Marks static SQLite connection/options as readonly. |
Mark single-assignment static fields readonly (VMACSService.sharedClient, RolesTests SQLite connection/options) and replace ContainsKey + indexer double lookups with TryGetValue (RotationsController recent-clinicians map, EmergencyContact test). Resolves cs/missed-readonly-modifier and cs/inefficient-containskey.
2186c20 to
1c007b7
Compare
|
@coderabbitai full review |
✅ Action performedFull review finished. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR makes two static fields readonly and changes two dictionary lookups to ChangesImmutable static fields
Safe dictionary lookup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
What
Five small CodeQL cleanups, behavior-preserving:
readonlyon single-assignment static fields (verified never reassigned):VMACSService.sharedClientRolesTests._sqlLiteConnection,_sqlLiteContextOptionsTryGetValueinstead ofContainsKey+ indexer (single lookup):RotationsController.BuildRecentCliniciansListrecent-clinicians map — usedTryGetValue(notGetValueOrDefault) to preserve exact behavior, sincePersonDisplayFullNameis nullableEmergencyContactControllerTestsphone-validation assertionResolves
cs/missed-readonly-modifier(#211, #212, #213) andcs/inefficient-containskey(#475, #479).Scope notes
Other alerts in the same batch were dismissed rather than changed:
cs/local-shadows-member×3 (idiomatic configure-setters) andcs/missed-ternary-operator×4 (subjective style / one not type-valid as a ternary).The agy review surfaced a separate pre-existing URL-encoding concern in
VMACSService.Search(DB-sourcedloginID, low exploitability) — left out of this PR to keep it scoped; tracked as a follow-up.