Skip to content

refactor(sonar): use optional chaining for nullable lookups (javascript:S6582) - #33

Merged
setchy merged 1 commit into
mainfrom
sonar/S6582-optional-chaining
Nov 5, 2026
Merged

setchy merged 1 commit into
mainfrom
sonar/S6582-optional-chaining

Conversation

@setchy

@setchy setchy commented Nov 4, 2026

Copy link
Copy Markdown
Member

Summary

Sonar rule javascript:S6582 asks for optional chaining instead of && guards when reading a nested property from a possibly-null value. Two guards in main.js used that older pattern.

Changes

  • gitify/contents/code/main.js: window.output && window.output.geometry → window.output?.geometry.
  • gitify/contents/code/main.js: lastAnchor && lastAnchor.pointer → lastAnchor?.pointer.

Both expressions keep the same semantics: undefined/null still short-circuits to undefined (falsy), so the existing branches are unchanged.

Verification

  • pnpm lint:check — passed
  • pnpm test — 28 passed, 0 failed

Sonar issues

https://sonarcloud.io/project/issues?id=gitify-app_kde&s=IMPACT_RANK&issueStatuses=OPEN&rules=javascript%3AS6582

@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

@setchy
setchy marked this pull request as ready for review November 4, 2026 17:27
@setchy
setchy requested a review from afonsojramos as a code owner November 4, 2026 17:27
@setchy
setchy merged commit 7b51c3b into main Nov 5, 2026
2 checks passed
@setchy
setchy deleted the sonar/S6582-optional-chaining branch November 5, 2026 19:18
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.

1 participant