Skip to content

Fix: avoid passing function reference directly to map() in ContributePage#3641

Merged
arkid15r merged 3 commits intoOWASP:mainfrom
Shubb07:fix/sonar-map-function
Feb 3, 2026
Merged

Fix: avoid passing function reference directly to map() in ContributePage#3641
arkid15r merged 3 commits intoOWASP:mainfrom
Shubb07:fix/sonar-map-function

Conversation

@Shubb07
Copy link
Contributor

@Shubb07 Shubb07 commented Jan 29, 2026

Proposed change

Resolves #3618

This PR fixes a SonarCloud reliability issue (typescript:S7727) in
frontend/src/app/contribute/page.tsx, where the function
renderContributeCard was passed directly to Array.map().

The code has been updated to use an explicit arrow function:
This makes the iterator arguments explicit, improves readability,
reduces the risk of subtle bugs during future refactors, and resolves
the Sonar warning without changing any existing behavior.

  • I followed the contributing workflow
  • I verified that my code works as intended and resolves the issue as described.
  • I ran make check-test locally: all warnings addressed, tests passed
  • I used AI for code, documentation, tests, or communication related to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 29, 2026

Summary by CodeRabbit

  • Bug Fixes
    • Improved stability of the contribution page to handle edge cases more gracefully.

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

Walkthrough

Replaced issues.map(renderContributeCard) with issues?.map((issue, index) => renderContributeCard(issue, index)) in frontend/src/app/contribute/page.tsx, adding an existence check and making the map callback parameters explicit without changing behavior.

Changes

Cohort / File(s) Summary
Contribute page
frontend/src/app/contribute/page.tsx
Changed issues.map(renderContributeCard) to issues?.map((issue, index) => renderContributeCard(issue, index)): added optional chaining and an explicit arrow callback to pass (issue, index) clearly.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Suggested reviewers

  • arkid15r
  • kasya
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main change: avoiding passing a function reference directly to map() in the ContributePage component.
Description check ✅ Passed The description is related to the changeset, explaining the SonarCloud issue being fixed and how the explicit arrow function approach addresses it.
Linked Issues check ✅ Passed The PR successfully addresses issue #3618 by replacing the direct function reference with an explicit arrow function that forwards iterator parameters, resolving the SonarCloud typescript:S7727 warning.
Out of Scope Changes check ✅ Passed The changes are focused and in-scope: only the map() call in frontend/src/app/contribute/page.tsx was modified to use an explicit arrow function with optional chaining, directly addressing the linked issue.
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 29, 2026
coderabbitai[bot]
coderabbitai bot previously approved these changes Jan 29, 2026
Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

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

Please resolve merge conflicts.

@arkid15r arkid15r marked this pull request as draft January 29, 2026 06:31
@Shubb07
Copy link
Contributor Author

Shubb07 commented Feb 2, 2026

Hi @arkid15r , please re-review the PR #3644 , so I could proceed with solving the merge conflicts of this one.

@arkid15r arkid15r marked this pull request as ready for review February 3, 2026 07:57
@arkid15r arkid15r enabled auto-merge February 3, 2026 07:57
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 3, 2026

@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.67%. Comparing base (3851523) to head (c8fb749).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #3641   +/-   ##
=======================================
  Coverage   87.67%   87.67%           
=======================================
  Files         462      462           
  Lines       14308    14309    +1     
  Branches     1910     1910           
=======================================
+ Hits        12544    12545    +1     
  Misses       1346     1346           
  Partials      418      418           
Flag Coverage Δ
backend 87.45% <ø> (ø)
frontend 88.27% <100.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
frontend/src/app/contribute/page.tsx 95.00% <100.00%> (+0.26%) ⬆️

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 3851523...c8fb749. 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.

@arkid15r arkid15r added this pull request to the merge queue Feb 3, 2026
Merged via the queue into OWASP:main with commit 722ea1b Feb 3, 2026
35 checks passed
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.

Sonar: Avoid passing function reference directly to map in ContributePage

2 participants

Comments