Skip to content

fix: resolve findings from the new SonarQube 26.9 rules - #246

Merged
ttbombadil merged 2 commits into
mainfrom
fix/sonar-new-rules
Oct 12, 2026
Merged

ttbombadil merged 2 commits into
mainfrom
fix/sonar-new-rules

Conversation

@ttbombadil

Copy link
Copy Markdown
Collaborator

Why

The local SonarQube server was updated to 26.9 on 2026-10-12; "Sonar way" gained ~50 TypeScript/JavaScript rules. Existing code (April–October) violated 23 of them, and because the new-code period runs since version 1.0, they counted as new and blocked every push in the pre-push gate.

Changes

  • server/services/tutor/curriculum/sketch-facts.ts (S8786): the array-size group \s*\[\s*([^\]]*)\s*\] had overlapping whitespace quantifiers (super-linear backtracking). Now \s*\[([^\]]*)\]; the captured size is trimmed before parsing, so results are unchanged. Curriculum tests green.
  • Scripts: startsWith instead of regex/slice (S6557), optional chains (S6582), explicit reduce seeds (S6959), safe stringification of unknown errors and ws RawData (S6551), if (!directory) (S3403). A follow-up commit replaces a nested ternary I introduced (S3358).
  • Tests (owner approved): 11 assertions use toHaveLength(...) instead of .length + toBe(...) (S5906), one presence check uses getByRole instead of queryByRole (S9027). Same expectations, better failure messages.

Test plan

  • Typecheck and ESLint clean; 188 directly affected tests green
  • ./run-tests.sh – all tests green (Docker 32/32, E2E 28/28)
  • Pre-push fresh Sonar scan: gate OK, 0 new violations, new coverage 83.6 %

Note: run-tests.sh only shows the last server-side gate unless REQUIRE_RELEASE_GATE=1; the fresh scan happens in the pre-push hook.

🤖 Generated with Claude Code

ttbombadil and others added 2 commits October 12, 2026 11:55
The Sonar way profiles gained about 50 rules on 2026-10-12; existing code
violated 23 of them and blocked the pre-push gate.

- sketch-facts: drop the redundant whitespace inside the array-size group,
  which caused super-linear backtracking; the group is trimmed anyway
- scripts: startsWith, optional chains, explicit reduce seeds, safe
  stringification of unknown errors and ws RawData
- tests: toHaveLength and getBy* presence assertions with the same
  expectations (approved by the owner)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ttbombadil
ttbombadil merged commit 2855b28 into main Oct 12, 2026
6 checks passed
@ttbombadil
ttbombadil deleted the fix/sonar-new-rules branch October 12, 2026 11:34
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