Skip to content

test: replace single-character regex alternation with character class#3400

Merged
arkid15r merged 1 commit intoOWASP:mainfrom
anukalp2804:fix/sonar-s6035-regex
Jan 18, 2026
Merged

test: replace single-character regex alternation with character class#3400
arkid15r merged 1 commit intoOWASP:mainfrom
anukalp2804:fix/sonar-s6035-regex

Conversation

@anukalp2804
Copy link
Contributor

@anukalp2804 anukalp2804 commented Jan 18, 2026

Proposed change

Fixes #3336

This PR updates a test regular expression by replacing a single-character alternation with a character class, addressing a SonarCloud code quality warning.

No functional behavior is changed.

Checklist

  • Required: I followed the contributing workflow
  • Required: I verified that my code works as intended and resolves the issue as described
  • Required: 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 18, 2026

Walkthrough

A regex pattern in the Pagination test was refactored to simplify single-character alternation. The pattern /^(Go to page (1|2))$/ was changed to /^(Go to page [12])$/ to resolve a SonarCloud code quality issue. The behavior remains unchanged.

Changes

Cohort / File(s) Summary
Test regex simplification
frontend/__tests__/unit/components/Pagination.test.tsx
Simplified regex pattern for button label matching from alternation group (1|2) to character class [12] in page navigation test

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

Suggested labels

frontend-tests

Suggested reviewers

  • arkid15r
  • kasya
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: simplifying a regex pattern from single-character alternation to a character class in a test file.
Linked Issues check ✅ Passed The pull request successfully addresses issue #3336 by replacing the single-character alternation (1|2) with a character class [12] in the regex pattern as required.
Out of Scope Changes check ✅ Passed The changes are narrowly scoped to a single regex pattern update in one test file, staying within the bounds of the linked issue's requirements.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The pull request description accurately describes the changeset: replacing a single-character regex alternation with a character class to address a SonarCloud warning, with no functional changes.

✏️ 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.

@sonarqubecloud
Copy link

@anukalp2804
Copy link
Contributor Author

@arkid15r
I’ve opened this PR to address the assigned issue. Please let me know if any changes are needed. Thanks!

@arkid15r arkid15r enabled auto-merge January 18, 2026 18:45
@arkid15r arkid15r added this pull request to the merge queue Jan 18, 2026
Merged via the queue into OWASP:main with commit eb555bf Jan 18, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sonar S6035: Replace single-character regex alternation with character class

2 participants

Comments