Skip to content

Fix safe SonarCloud issues (imports, assertions, optional chaining)#1476

Merged
mathuo merged 1 commit into
v8-branchfrom
claude/sonar-safe-fixes-v8
Jul 16, 2026
Merged

Fix safe SonarCloud issues (imports, assertions, optional chaining)#1476
mathuo merged 1 commit into
v8-branchfrom
claude/sonar-safe-fixes-v8

Conversation

@mathuo

@mathuo mathuo commented Jul 16, 2026

Copy link
Copy Markdown
Owner

Description

Follow-up to #1473. Addresses the low-risk, mechanical SonarCloud findings that were surfaced (at the file level) on the code the comment-cleanup pass touched. These were all pre-existing nits, not introduced by that PR. No behaviour changes.

Fixed (66 issues)

Rule Count Change
S3863 49 Merge the multiple from 'dockview' imports in each enterprise service into one statement (identical specifiers, other imports untouched)
S5906 10 expect(x).toHaveLength(n) instead of expect(x.length).toBe(n) in tests
S6582 3 Optional chaining where exactly equivalent (!service?.includes(...), existing?.tagName, !parsed?.validUntil)
S3358 2 Extract a nested ternary into if/else (keyboard-nav focus wrap)
S7762 1 firstChild.remove() instead of removeChild(firstChild)
S6606 1 visible ?? true instead of an !== undefined ternary

Deliberately left alone (documented so they aren't mistaken for oversights)

  • S7747 (4) — the for..of [...set] spreads are defensive copies; the loop body mutates the collection (_endSession / detach / delete), so dropping the copy would iterate over a mutating set. Sonar can't see the mutation.
  • S7758 / S6035 (3)charCodeAt / regex alternation live in the license checksum, which is byte-compatible with the key issuer. Changing them risks license-validation drift.
  • S3735 (2) — the void operators intentionally mark ignored promises.
  • S3776 (9) — cognitive-complexity refactors carry behavioural risk; out of scope for a nit pass.
  • S2301, S4144, css S4666, S1135, and 3 further S6582 — intentional design (boolean-flag method, two typed never-fire event fallbacks, a deliberately split CSS ruleset with a specificity comment, a real TODO) or would break TypeScript narrowing.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Refactor / cleanup
  • Build / CI / tooling

Affected packages

  • dockview-core
  • dockview (vanilla JS)
  • dockview-react
  • dockview-vue
  • dockview-angular
  • docs

Also touches dockview-enterprise.

How to test

Each change is behaviour-preserving. The import merges were verified to keep an identical specifier set per file (checked programmatically). The optional-chaining and nullish-coalescing rewrites are exact equivalents; the toHaveLength and nested-ternary changes are covered by the existing test suites. CI (lint, format, build, test) is the gate.

Checklist

  • yarn lint:fix passes
  • yarn format passes
  • npm run gen has been run and generated files are up to date
  • yarn test passes
  • I have added or updated tests where applicable
  • Breaking changes are documented

🤖 Generated with Claude Code

https://claude.ai/code/session_01UZrBEk48dxvwBR6VkskSxw


Generated by Claude Code

Address the low-risk, mechanical SonarCloud findings surfaced on the code
touched by the comment-cleanup pass. Behaviour is unchanged.

- S3863 (x49): merge the multiple `from 'dockview'` imports in each enterprise
  service into a single import statement (same specifiers, no reordering of
  other imports).
- S5906 (x10): use `toHaveLength(n)` instead of `expect(x.length).toBe(n)` in
  tests for clearer failure messages.
- S6582 (x3): use optional chaining where it is exactly equivalent
  (`!service?.includes(...)`, `existing?.tagName`, `!parsed?.validUntil`).
- S3358 (x2): extract a nested ternary into an if/else in the keyboard-nav
  focus-wrap calc.
- S7762 (x1): `firstChild.remove()` instead of `removeChild(firstChild)`.
- S6606 (x1): nullish coalescing (`visible ?? true`) instead of an
  `!== undefined` ternary.

Deliberately left alone (documented so they are not mistaken for oversights):
- S7747 (x4): the `for..of [...set]` spreads are defensive copies; the loop
  body mutates the collection (`_endSession`/`detach`/delete), so removing the
  copy would iterate over a mutating set.
- S7758/S6035 (x3): `charCodeAt`/regex in the license checksum are
  byte-compatible with the key issuer; changing them risks validation drift.
- S3735 (x2): the `void` operators mark intentionally-ignored promises.
- S3776 (x9): cognitive-complexity refactors carry behavioural risk and are out
  of scope for a nit pass.
- S2301, S4144, css S4666, S1135, and 3 further S6582: intentional design
  (boolean-flag method, typed never-fire event fallbacks, a deliberately split
  CSS ruleset, a real TODO) or would break type narrowing.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UZrBEk48dxvwBR6VkskSxw
@sonarqubecloud

Copy link
Copy Markdown

@mathuo
mathuo merged commit b6d36e9 into v8-branch Jul 16, 2026
9 checks passed
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