[HOTE-974] feat: [SonarQube] Address issues in UI#287
Merged
Conversation
# Conflicts: # ui/src/routes/HomeTestTermsOfUsePage.tsx
Contributor
There was a problem hiding this comment.
Pull request overview
Addresses a set of SonarQube-reported issues across the UI package by making small refactors to types, array access, optional chaining, and regex usage, plus a Jest test setup adjustment.
Changes:
- Introduce a reusable
LookupResultsStatusunion type for postcode lookup state. - Replace manual “last element” indexing with
Array.prototype.at(-1)and simplify null/empty checks via optional chaining. - Refactor some regex parsing to use
RegExp.prototype.execand adjust Jest sessionStorage mocking.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ui/src/state/PostcodeLookupContext.tsx | Extracts lookupResultsStatus union into a named LookupResultsStatus type to remove duplication. |
| ui/src/state/NavigationContext.tsx | Uses .at(-1) for last-step retrieval in step history logic. |
| ui/src/routes/get-self-test-kit-for-HIV-journey/SelectDeliveryAddressPage.tsx | Reorders imports and simplifies LA supplier availability check using optional chaining. |
| ui/src/routes/get-self-test-kit-for-HIV-journey/EnterAddressManuallyPage.tsx | Reorders imports and simplifies LA supplier availability check using optional chaining. |
| ui/src/routes/HomeTestTermsOfUsePage.tsx | Refactors numeric-prefix parsing from .match() to .exec(). |
| ui/src/routes/HomeTestPrivacyPolicyPage.tsx | Refactors numeric-prefix parsing from .match() to .exec() and normalises import ordering. |
| ui/jest.setup.ts | Changes sessionStorage mock assignment/clearing to use globalThis. |
|
TSeelig
approved these changes
Mar 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
https://nhsd-jira.digital.nhs.uk/browse/HOTE-974
Context
Type of changes
Checklist
Sensitive Information Declaration
To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.