CodeQL 16: refactor: remove useless upcasts via record types and default(T)#202
CodeQL 16: refactor: remove useless upcasts via record types and default(T)#202rlorenzo wants to merge 3 commits into
Conversation
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 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 |
Bundle ReportBundle size has no change ✅ |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #202 +/- ##
=======================================
Coverage 42.96% 42.96%
=======================================
Files 877 877
Lines 51468 51470 +2
Branches 4802 4802
=======================================
+ Hits 22113 22114 +1
- Misses 28831 28832 +1
Partials 524 524
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
…ilters Removed 'Microsoft.EntityFrameworkCore.' and 'Microsoft.Data.SqlClient.' prefixes from the catch when-filters added in codeql/15. Added 'using Microsoft.Data.SqlClient;' to EmailNotificationTest.
8b79d57 to
e1282ea
Compare
Summary
Closes 6 of the 7 non-test
cs/useless-upcastalerts by either extracting a named record or replacing(T?)nullwithdefault(T?):PhotoExportService.BatchLoadPhotosAsync(PhotoExportService.cs:906, 911, 916, 921) - replaces the 4 anonymous types with a privatePhotoLookupResult(string MailId, byte[]? PhotoBytes)record. The catch branches now returnnew PhotoLookupResult(s.MailId, null)- no cast needed because the parameter is typed.VerificationService.cs:235-(DateTime?)null→default(DateTime?). Same value, no cast.CliniciansController.cs:204-(string?)null→default(string). The two anonymous types in the if/else assign to anobjectvariable, so they don't need to match._EmailLayout.cshtml:46,48- extractedvar baseUrl = ViewBag.BaseUrl as string;into a Razor block; the(string?)/(string)casts on every reference go away.Not addressed
The 1 remaining non-test useless-upcast alert is essentially the same site as above - they collapse together once CodeQL re-scans.
Context
Sixteenth in the
CodeQL N:cleanup series.Test plan
npm run test:backend- 1946 tests passingnpm run verify:build- clean