Skip to content

Resolve SonarQube findings across the codebase - #1397

Open
LunaUrsa wants to merge 1 commit into
uatfrom
fix/sonar-issues
Open

LunaUrsa wants to merge 1 commit into
uatfrom
fix/sonar-issues

Conversation

@LunaUrsa

Copy link
Copy Markdown
Contributor

Summary

Clears the 1,404 open findings on the SonarQube server for this project.

  • Removed commented-out code (S125, 867 findings).
  • Bug-level fixes: regex precedence, string .sort() without a compare function, matrix case 'lsd' || 'acid', and the sample DB password in an env.validate help text.
  • Mechanical rules: ignored exceptions, unused imports, ?? / ?. / readonly, unnecessary assertions, nested ternaries and similar.
  • Refactored 66 over-complex functions into helpers or lookup tables (levels/profile/leaderboard cards, rpg, counting, privacy, combo, botmod, timer, reaction roles, etc.). Behavior is intended to be identical.
  • Rewrote 18 assertion-less tests; renamed matrix m.test.ts to m.roletest.ts so Sonar doesn't treat it as a test file.
  • messageModThread and idose now take an options object (callers and tests updated).
  • Added src/**/archive/** to sonar.exclusions.

Things to review

  • || to ?? conversions: an empty string no longer falls back to the default (e.g. an empty KEYCLOAK_URL). Cases where it mattered (user limit 0, trimmed-empty to null, boolean contexts) keep their old behavior.
  • describeChannels output now sorts with localeCompare (emoji-first names move); its test was updated.
  • Canvas card refactors (/levels, /profile, /leaderboard) have no pixel-level test and deserve a visual check.
  • Matrix files were edited but are excluded from tsc and the tests.

Verification

  • tsc (app, vitest and prisma configs), ESLint on changed files, git diff --check: clean.
  • npm run tripbot:test: 2,263 passed.
  • Not verified: a Sonar rescan. The count on the server only updates when CI scans this branch.

No Discord command definitions changed, so there is nothing to register on startup.

Tracks reworded TODO comments in #1396.

🤖 Generated with Claude Code

Clears the open findings reported by the SonarQube server (1,404):
- remove commented-out code (S125)
- fix bug-level items: regex precedence, string sorts without a compare
  function, matrix switch fall-through, sample DB password in a help text
- handle ignored exceptions, drop unused imports, prefer ?? / ?. / readonly,
  remove unnecessary assertions, and similar mechanical rules
- refactor 66 over-complex functions into helpers or lookup tables
  (levels/profile/leaderboard cards, rpg, counting, privacy, combo, botmod,
  timer, reaction roles and more) with behavior unchanged
- rewrite assertion-less tests; rename matrix m.test.ts to m.roletest.ts
- messageModThread and idose now take an options object
- exclude archived code from Sonar analysis

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@LunaUrsa
LunaUrsa requested a review from a team as a code owner November 15, 2026 03:32

/** Plain values keep their usual text; structured values are serialized instead of printing "[object Object]". */
function formatValue(value: unknown): string {
if (typeof value === 'object' && value !== null && !(value instanceof Date)) {
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