Skip to content

[HOTE-974] feat: [SonarQube] Address issues in UI#287

Merged
cptiv2020 merged 10 commits intomainfrom
feature/hote-974/sonarqube-issues-fixes
Mar 27, 2026
Merged

[HOTE-974] feat: [SonarQube] Address issues in UI#287
cptiv2020 merged 10 commits intomainfrom
feature/hote-974/sonarqube-issues-fixes

Conversation

@cptiv2020
Copy link
Copy Markdown
Contributor

@cptiv2020 cptiv2020 commented Mar 26, 2026

Description

https://nhsd-jira.digital.nhs.uk/browse/HOTE-974

Context

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I am familiar with the contributing guidelines
  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming

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.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

Copilot AI review requested due to automatic review settings March 26, 2026 14:37
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 26, 2026

Lambdas Coverage Report

Lines Statements Branches Functions
Coverage: 96%
97% (1164/1200) 89.9% (365/406) 94.14% (177/188)

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 26, 2026

UI Coverage Report

Lines Statements Branches Functions
Coverage: 95%
95.35% (5356/5617) 86.77% (610/703) 87.05% (195/224)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 LookupResultsStatus union 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.exec and 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.

Comment thread ui/jest.setup.ts
@sonarqubecloud
Copy link
Copy Markdown

@cptiv2020 cptiv2020 merged commit 20a9832 into main Mar 27, 2026
11 checks passed
@cptiv2020 cptiv2020 deleted the feature/hote-974/sonarqube-issues-fixes branch March 27, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants