CodeQL 15: chore(tests): narrow catch(Exception) to specific types in test helpers#201
CodeQL 15: chore(tests): narrow catch(Exception) to specific types in test helpers#201rlorenzo wants to merge 2 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✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #201 +/- ##
=======================================
Coverage 42.96% 42.96%
=======================================
Files 877 877
Lines 51468 51468
Branches 4802 4802
=======================================
Hits 22113 22113
Misses 28831 28831
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.
Summary
Closes 5 of the remaining
cs/catch-of-all-exceptionsalerts in test code by narrowing the catch to the specific types each test helper is actually expecting:test/CTS/AssessmentControllerTest.cs:266,282-IsForbidResult/IsNotFoundResulthelpers convert xUnit assertion failures tofalse. Narrowed fromcatch (Exception)tocatch (Xunit.Sdk.XunitException), which is exactly whatAssert.X(...)throws.test/ClinicalScheduler/EmailNotificationTest.cs:284,466- diagnostic try/catch aroundRemoveInstructorScheduleAsync. Narrowed towhen (ex is InvalidOperationException or DbUpdateException or SqlException or OperationCanceledException)- the actual exception families that production code throws (matches the service'swhenfilter from CodeQL 5: refactor(ClinicalScheduler): catch specific exceptions in services #193).test/ClinicalScheduler/RotationServiceTest.cs:98- test-data-seeding try/catch aroundSaveChanges. Narrowed towhen (ex is DbUpdateException or InvalidOperationException).Context
Fifteenth in the
CodeQL N:cleanup series. (The PDF/Excelcs/linq/missed-selectSelect-conversion attempted on this branch was reverted - the script over-matched loops where the iter var is also used in headers/totals/spacers, breaking compilation. Those remaining 19 alerts genuinely require the iter var and can't be cleanly converted.)Test plan
npm run test:backend- 1946 tests passing