Skip to content

Resolve behaviour-neutral SonarCloud code smells - #471

Merged
ilovepixelart merged 2 commits into
mainfrom
sonar-behaviour-neutral-smells
Nov 17, 2026
Merged

ilovepixelart merged 2 commits into
mainfrom
sonar-behaviour-neutral-smells

Conversation

@ilovepixelart

@ilovepixelart ilovepixelart commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Resolves 15 of the 20 open SonarCloud findings on main with behaviour-neutral rewrites.

  • Nested ternaries (S3358) become if/else: optionLine row color and textField reserved width in question.ts, shellCompletionText in internal/background-shells.ts, manifest hook entries in loadPluginHooks (hooks/config.ts).
  • Nested template literals (S4624) are split into named locals in question.ts (renderOptions, batch result rendering, chatResult, renderTabs) and skills.ts (plugin skill command handler, bareFormRefusal).
  • unconfirmedText, confirm and followEdits (S7721) move from the askViaOverlay closure to module scope; they read only their arguments and multiAnswer. toggleChecked, which calls only followEdits, moves with them.
  • Random IDs in monitor.ts and background-bash.ts strip dashes with replaceAll('-', '') instead of replace(/-/g, '') (S7781).

Output strings, generated IDs and control flow are unchanged; the existing suites for these paths pass unmodified.

The remaining five findings are not changed in code:

  • memory.ts:98 (S7767, S7758): claudePathHash reproduces Claude Code's 32-bit string hash over UTF-16 code units to name its project directory; Math.trunc and codePointAt would produce different directory names.

  • monitor.ts:267 (S6551): end.error is the rejection of the bash tool's execute, which only ever rejects with an Error; the String() branch is a fallback for the unknown type.

  • question.ts:134 (S2301): checkbox(checked) renders a checkbox state, not an action selector.

  • todo.ts:347 (S1135): the matched word is the feature name in "Register the branch-local Todo provider", not a TODO marker.

  • npm run check passes (Biome, strict tsc, knip, Vitest)

  • Tests cover the change (existing suites; no behaviour change)

- Replace nested ternaries with if/else in question.ts (row color,
  reserved text-field width), background-shells.ts (completion wording)
  and hooks/config.ts (manifest hook entries).
- Split nested template literals into named locals in question.ts and
  skills.ts.
- Hoist unconfirmedText, confirm and followEdits out of the
  askViaOverlay closure; none of them reads closure state.
- Strip dashes from random IDs with replaceAll('-', '') instead of a
  global regex in monitor.ts and background-bash.ts.

Output strings, IDs and control flow are unchanged.
It reads only its argument and followEdits, which is now module-level.
@sonarqubecloud

Copy link
Copy Markdown

@ilovepixelart
ilovepixelart merged commit 6af5101 into main Nov 17, 2026
13 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