Skip to content

CodeQL 16: refactor: remove useless upcasts via record types and default(T)#202

Open
rlorenzo wants to merge 3 commits into
mainfrom
codeql/16-extract-record-types
Open

CodeQL 16: refactor: remove useless upcasts via record types and default(T)#202
rlorenzo wants to merge 3 commits into
mainfrom
codeql/16-extract-record-types

Conversation

@rlorenzo
Copy link
Copy Markdown
Contributor

@rlorenzo rlorenzo commented May 13, 2026

Summary

Closes 6 of the 7 non-test cs/useless-upcast alerts by either extracting a named record or replacing (T?)null with default(T?):

  • PhotoExportService.BatchLoadPhotosAsync (PhotoExportService.cs:906, 911, 916, 921) - replaces the 4 anonymous types with a private PhotoLookupResult(string MailId, byte[]? PhotoBytes) record. The catch branches now return new PhotoLookupResult(s.MailId, null) - no cast needed because the parameter is typed.
  • VerificationService.cs:235 - (DateTime?)nulldefault(DateTime?). Same value, no cast.
  • CliniciansController.cs:204 - (string?)nulldefault(string). The two anonymous types in the if/else assign to an object variable, so they don't need to match.
  • _EmailLayout.cshtml:46,48 - extracted var 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 passing
  • npm run verify:build - clean
  • Pre-commit lint+test+verify all passed

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • review-ready

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 8508783e-2b1d-4193-a8bc-42b5af52bd1c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codeql/16-extract-record-types

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.

@codecov-commenter
Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 13, 2026

Codecov Report

❌ Patch coverage is 22.22222% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.96%. Comparing base (38de1ad) to head (e1282ea).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
web/Areas/Students/Services/PhotoExportService.cs 0.00% 5 Missing ⚠️
...nicalScheduler/Controllers/CliniciansController.cs 0.00% 1 Missing ⚠️
...eb/EmailTemplates/Views/Shared/_EmailLayout.cshtml 50.00% 0 Missing and 1 partial ⚠️
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           
Flag Coverage Δ
backend 43.04% <22.22%> (+<0.01%) ⬆️
frontend 41.34% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

rlorenzo added 2 commits May 13, 2026 02:19
…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.
@rlorenzo rlorenzo force-pushed the codeql/16-extract-record-types branch from 8b79d57 to e1282ea Compare May 13, 2026 09:22
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.

2 participants