Skip to content

Refactor programs page to use optional chaining (S6582)#3486

Merged
kasya merged 3 commits intoOWASP:mainfrom
Shubb07:fix/optional-chaining-programs-page
Jan 23, 2026
Merged

Refactor programs page to use optional chaining (S6582)#3486
kasya merged 3 commits intoOWASP:mainfrom
Shubb07:fix/optional-chaining-programs-page

Conversation

@Shubb07
Copy link
Contributor

@Shubb07 Shubb07 commented Jan 23, 2026

Resolves #3467

This PR replaces defensive logical AND checks with optional chaining in the programs page, improving readability and resolving SonarCloud rule typescript:S6582.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Summary by CodeRabbit

  • Refactor
    • Simplified null/undefined handling in the mentorship programs listing to improve code clarity and maintainability; no changes to functionality, UI, or user experience.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Replaced a defensive logical-AND guard on the programs array with optional chaining in the mentorship programs page: programs && programs.filter(...).map(...)programs?.filter(...).map(...). No other logic, control flow, or exported declarations were changed.

Changes

Cohort / File(s) Summary
Optional chaining refactor
frontend/src/app/mentorship/programs/page.tsx
Replaced programs && programs.filter(...).map(...) with programs?.filter(...).map(...) to use optional chaining (addresses SonarCloud rule S6582).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Suggested reviewers

  • arkid15r
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: refactoring to use optional chaining on the programs page to address SonarCloud rule S6582.
Description check ✅ Passed The description is directly related to the changeset, explaining that it replaces logical AND checks with optional chaining and resolves the linked issue.
Linked Issues check ✅ Passed The pull request successfully addresses issue #3467 by replacing defensive logical AND checks with optional chaining in the programs page file.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objective of refactoring the programs page to use optional chaining; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 23, 2026
Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shubb07 Thanks for updating this!
Could you also update all places where this happens? I believe there 6 files in total
https://sonarcloud.io/project/issues?rules=typescript%3AS6582&issueStatuses=OPEN%2CCONFIRMED&id=OWASP_Nest

coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 23, 2026
@kasya
Copy link
Collaborator

kasya commented Jan 23, 2026

I just noticed another PR addresses the same issue 👀 but also not all 6 files 😓
Ok! Let's keep it as is then.

@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (main@204f833). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3486   +/-   ##
=======================================
  Coverage        ?   85.60%           
=======================================
  Files           ?      461           
  Lines           ?    14221           
  Branches        ?     1893           
=======================================
  Hits            ?    12174           
  Misses          ?     1678           
  Partials        ?      369           
Flag Coverage Δ
backend 84.47% <ø> (?)
frontend 88.74% <100.00%> (?)

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

Files with missing lines Coverage Δ
frontend/src/app/mentorship/programs/page.tsx 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 204f833...1dc06d1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Shubb07 thanks for updating this!
Please run make check-test next time before pushing changes 👍🏼

@kasya kasya enabled auto-merge January 23, 2026 04:11
@kasya kasya added this pull request to the merge queue Jan 23, 2026
@kasya kasya removed this pull request from the merge queue due to a manual request Jan 23, 2026
@kasya kasya added this pull request to the merge queue Jan 23, 2026
Merged via the queue into OWASP:main with commit b91bbc5 Jan 23, 2026
35 of 36 checks passed
@Shubb07
Copy link
Contributor Author

Shubb07 commented Jan 23, 2026

Hey @kasya , I will surely run the make check test next time before raising the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor programs page to use optional chaining (SonarCloud S6582)

3 participants