fix: remove redundant type assertion in EditProgramPage#3653
fix: remove redundant type assertion in EditProgramPage#3653Adarshkumar0509 wants to merge 3 commits intoOWASP:mainfrom
Conversation
Remove the unnecessary (session as ExtendedSession) cast as it does not change the type, addressing SonarQube rule typescript:S4325. The type assertion was redundant because the compiler already infers the session type correctly in this context.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings. WalkthroughRemoved a duplicate Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
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 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@frontend/src/app/my/mentorship/programs/`[programKey]/edit/page.tsx:
- Around line 56-58: Add a type-safe cast for session when accessing user.login:
import the ExtendedSession type (import type { ExtendedSession } from
'types/auth') and update the isAdmin check in the isAdmin computation (the
expression using data.getProgram.admins and session) to compare admin.login
against (session as ExtendedSession)?.user?.login so the login property access
is type-safe and matches the pattern used elsewhere.
frontend/src/app/my/mentorship/programs/[programKey]/edit/page.tsx
Outdated
Show resolved
Hide resolved
|
Changes requested by CodeRabbit have been applied; ready for another look. |
|
| const isAdmin = data.getProgram.admins?.some( | ||
| (admin: { login: string }) => admin.login === (session as ExtendedSession)?.user?.login | ||
| ) |
There was a problem hiding this comment.
Why did you change indentation here? And I believe the assertion (the issue you needed to fix) is still there 👀
|
Closing this in favor of #3628 |



This PR addresses the SonarQube code smell (typescript:S4325) by removing a redundant type assertion in the EditProgramPage component.
Changes
(session as ExtendedSession)cast infrontend/src/app/my/mentorship/programs/[programKey]/edit/page.tsxExtendedSessionimportTesting
Issue
Fixes SonarQube rule typescript:S4325: Redundant casts and non-null assertions should be avoided
This improves code maintainability by removing unnecessary type assertions.
Resolves #3554