Fix safe SonarCloud issues (imports, assertions, optional chaining)#1476
Merged
Conversation
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
|
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
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)
from 'dockview'imports in each enterprise service into one statement (identical specifiers, other imports untouched)expect(x).toHaveLength(n)instead ofexpect(x.length).toBe(n)in tests!service?.includes(...),existing?.tagName,!parsed?.validUntil)firstChild.remove()instead ofremoveChild(firstChild)visible ?? trueinstead of an!== undefinedternaryDeliberately left alone (documented so they aren't mistaken for oversights)
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.charCodeAt/ regex alternation live in the license checksum, which is byte-compatible with the key issuer. Changing them risks license-validation drift.voidoperators intentionally mark ignored promises.Type of change
Affected packages
dockview-coredockview(vanilla JS)dockview-reactdockview-vuedockview-angulardocsAlso 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
toHaveLengthand nested-ternary changes are covered by the existing test suites. CI (lint, format, build, test) is the gate.Checklist
yarn lint:fixpassesyarn formatpassesnpm run genhas been run and generated files are up to dateyarn testpasses🤖 Generated with Claude Code
https://claude.ai/code/session_01UZrBEk48dxvwBR6VkskSxw
Generated by Claude Code