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
|
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 (3)
📝 WalkthroughWalkthroughException handling across three test files is narrowed from catching generic ChangesTest exception handling narrowing
🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
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.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
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