Skip to content

fix(sonar): use nullish coalescing assignment - #3812

Merged
lhein merged 1 commit into
KaotoIO:mainfrom
etzel-mes:fix/issue-3737-nullish-assignment
Aug 28, 2026
Merged

fix(sonar): use nullish coalescing assignment#3812
lhein merged 1 commit into
KaotoIO:mainfrom
etzel-mes:fix/issue-3737-nullish-assignment

Conversation

@etzel-mes

@etzel-mes etzel-mes commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Description

Replace five conditional nullish initialization patterns with the nullish coalescing assignment operator, addressing Sonar rule typescript:S6606 while preserving existing behavior.

Closes #3737

Type of Change

  • Bug fix
  • New feature
  • Improvement
  • Documentation update
  • Other

How Has This Been Tested?

  • Focused tests for BeansEntityHandler, PipeErrorHandlerPage, EventNotifier, ExtensionRegistry, and NodeNamespaceContext — 45 tests passed
  • yarn workspace @kaoto/kaoto lint
  • yarn workspace @kaoto/kaoto lint:style

Checklist

  • I have read the Contributing Guidelines.
  • I have followed the coding style and conventions of the project.
  • I have tested my changes and ensured that they work as expected.
  • Documentation update — not applicable to this code-quality cleanup.
  • New tests — existing focused tests cover the unchanged initialization behavior.

AI assistance was used. The change was reviewed and approved by the human operator before submission.

Summary by CodeRabbit

  • Refactor
    • Streamlined internal initialization logic across visualization, error handling, event notification, XML deserialization, and namespace processing.
    • Preserved existing behavior while making lazy creation and caching more concise and consistent.

@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8035568c-13f7-4f09-bea4-c72ba7962ec1

📥 Commits

Reviewing files that changed from the base of the PR and between c07cde3 and 4ac2ddd.

📒 Files selected for processing (5)
  • packages/ui/src/models/visualization/metadata/beans-entity-handler.ts
  • packages/ui/src/pages/PipeErrorHandler/PipeErrorHandlerPage.tsx
  • packages/ui/src/utils/event-notifier.ts
  • packages/ui/src/xml-schema-ts/extensions/DefaultExtensionDeserializer.ts
  • packages/ui/src/xml-schema-ts/utils/NodeNamespaceContext.ts

Included review availability: Your plan provides up to 2 included reviews per hour; 1 remains after this review.


📝 Walkthrough

Walkthrough

The changes replace five explicit null-check initialization blocks with the ??= operator. The affected code covers beans entities, pipe error handler entities, the event notifier singleton, extension metadata maps, and namespace prefix caches.

Changes

Nullish assignment cleanup

Layer / File(s) Summary
Replace conditional initialization
packages/ui/src/models/visualization/metadata/beans-entity-handler.ts, packages/ui/src/pages/PipeErrorHandler/PipeErrorHandlerPage.tsx, packages/ui/src/utils/event-notifier.ts, packages/ui/src/xml-schema-ts/extensions/DefaultExtensionDeserializer.ts, packages/ui/src/xml-schema-ts/utils/NodeNamespaceContext.ts
Five explicit initialization guards now use nullish coalescing assignment. Existing initialization behavior remains unchanged.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 4ac2d

This is a localized code-quality cleanup that preserves existing lazy-initialization behavior, with no actionable merge-blocking risk remaining after normal checks and review.

Suggested reviewers: lhein

Poem

A rabbit spots five guards in line
And swaps each one for ??= shine
The caches wake when values flee
The singleton stays lazily
Clean code hops through every vine

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: replacing conditional initialization with nullish coalescing assignment to address Sonar.
Linked Issues check ✅ Passed The PR updates all five files listed in issue #3737 and replaces the specified conditional initialization patterns with ??= while preserving behavior.
Out of Scope Changes check ✅ Passed The changes are limited to the five files and the nullish initialization refactoring required by issue #3737. No unrelated changes are identified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 5…
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 5 files.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@lordrip lordrip left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution @etzel-mes 👍

@igarashitm
igarashitm force-pushed the fix/issue-3737-nullish-assignment branch from 4ac2ddd to e8a463e Compare August 28, 2026 13:37
@lhein
lhein force-pushed the fix/issue-3737-nullish-assignment branch from e8a463e to 87a4edf Compare August 28, 2026 17:39
@sonarqubecloud

Copy link
Copy Markdown

@lhein
lhein merged commit 025ac89 into KaotoIO:main Aug 28, 2026
20 of 21 checks passed
@lhein

lhein commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Thank you, @etzel-mes

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.

Fix typescript:S6606: Use nullish coalescing assignment (??=) instead of conditional assignment

4 participants