[Tech debt] SonarQube: assorted backend code smells (S2699, S2365, S3973, S131, email-verified.html) #249

Closed
opened 2026-06-19 18:45:07 +00:00 by spikerj · 3 comments
Owner

Roll-up of low-volume HIGH/BLOCKER MAINTAINABILITY smells in our backend code.

Items

  • csharpsquid:S2699 (BLOCKER) — test has no assertion. SpikerSoft.Tests.Unit/Services/FileHashServicePerformanceTests.cs:173
  • csharpsquid:S2365 (CRITICAL) — property copies a collection on each access; convert ActionKeys to a method. SpikerSoft.Business/Domain/Activity/KnowledgeDomainRegistry.cs:17
  • csharpsquid:S3973 (CRITICAL) — use braces/indentation for the for body. SpikerSoft.Business/Domain/Lessons/Curriculum/Tier05_Collections/Lesson505_TwoDArray.cs:21
  • shelldre:S131 (CRITICAL) — add a default *) case to the case statement. SpikerSoft.Api/certs/generate-internal-certs.sh:313
  • javascript:S3776 (CRITICAL ×2) — cognitive complexity 32 in inline script. SpikerSoft.Api/wwwroot/email-verified.html:703, 1010
  • javascript:S7761 (MAJOR ×2) — prefer .dataset over getAttribute(). SpikerSoft.Api/wwwroot/email-verified.html:692, 697

Check off as fixed.

Roll-up of low-volume HIGH/BLOCKER MAINTAINABILITY smells in our backend code. ## Items - [ ] `csharpsquid:S2699` (BLOCKER) — test has no assertion. `SpikerSoft.Tests.Unit/Services/FileHashServicePerformanceTests.cs:173` - [ ] `csharpsquid:S2365` (CRITICAL) — property copies a collection on each access; convert `ActionKeys` to a method. `SpikerSoft.Business/Domain/Activity/KnowledgeDomainRegistry.cs:17` - [ ] `csharpsquid:S3973` (CRITICAL) — use braces/indentation for the `for` body. `SpikerSoft.Business/Domain/Lessons/Curriculum/Tier05_Collections/Lesson505_TwoDArray.cs:21` - [ ] `shelldre:S131` (CRITICAL) — add a default `*)` case to the `case` statement. `SpikerSoft.Api/certs/generate-internal-certs.sh:313` - [ ] `javascript:S3776` (CRITICAL ×2) — cognitive complexity 32 in inline script. `SpikerSoft.Api/wwwroot/email-verified.html:703, 1010` - [ ] `javascript:S7761` (MAJOR ×2) — prefer `.dataset` over `getAttribute()`. `SpikerSoft.Api/wwwroot/email-verified.html:692, 697` Check off as fixed.
spikerj added the sonarqube label 2026-06-19 18:45:07 +00:00
Author
Owner

Partially resolved in spikersoft-backend PR #12 (merged to master):

  • S2365ActionKeys converted to a cached GetActionKeys() method (+ 5 callers).
  • S3973 — braces added to the nested loop in Lesson505_TwoDArray.
  • S131 — default *) case added to generate-internal-certs.sh.
  • S7761 ×2 — dataset over getAttribute() in email-verified.html.
  • S2699 — timing assertions added to FileHashServicePerformanceTests.

Remaining (ticket stays open):

  • javascript:S3776 ×2 — cognitive complexity in the inline game JS at email-verified.html:703, 1010. Deferred from this mechanical pass; it needs a real refactor of that inline script.
Partially resolved in spikersoft-backend PR #12 (merged to `master`): - [x] `S2365` — `ActionKeys` converted to a cached `GetActionKeys()` method (+ 5 callers). - [x] `S3973` — braces added to the nested loop in `Lesson505_TwoDArray`. - [x] `S131` — default `*)` case added to `generate-internal-certs.sh`. - [x] `S7761` ×2 — `dataset` over `getAttribute()` in `email-verified.html`. - [x] `S2699` — timing assertions added to `FileHashServicePerformanceTests`. Remaining (ticket stays open): - [ ] `javascript:S3776` ×2 — cognitive complexity in the inline game JS at `email-verified.html:703, 1010`. Deferred from this mechanical pass; it needs a real refactor of that inline script.
Author
Owner

Last remaining items up for review in spikersoft-backend PR #46:

  • javascript:S3776 ×2 — email-verified.html:703 (handleMobileControl) and :1010 (handleKeyDown), both Cognitive Complexity 32 → within limit.

Both functions were duplicated portrait/landscape switch blocks where every branch applied the same "don't reverse into your own neck" rule; collapsed them into a key→direction lookup + two small shared helpers (remapDirection, applyDirection) reusing the existing areDirectionsOpposite guard. Behavior verified identical; SonarQube snippet analysis reports 0 issues. Will close this ticket once #46 merges — that completes all of #249's scope (the rest landed in backend PR #12).

Last remaining items up for review in spikersoft-backend PR #46: - [x] `javascript:S3776` ×2 — `email-verified.html:703` (`handleMobileControl`) and `:1010` (`handleKeyDown`), both Cognitive Complexity 32 → within limit. Both functions were duplicated portrait/landscape `switch` blocks where every branch applied the same "don't reverse into your own neck" rule; collapsed them into a key→direction lookup + two small shared helpers (`remapDirection`, `applyDirection`) reusing the existing `areDirectionsOpposite` guard. Behavior verified identical; SonarQube snippet analysis reports 0 issues. Will close this ticket once #46 merges — that completes all of #249's scope (the rest landed in backend PR #12).
Author
Owner

Resolved in spikersoft-backend PR #46 (merged to master). Refactored the two javascript:S3776 cognitive-complexity functions in email-verified.html (handleMobileControl, handleKeyDown) from 32 down to within the limit via a key→direction lookup + shared remapDirection/applyDirection helpers. That completes all of #249's scope (the other items — S2365, S3973, S131, S7761×2, S2699 — landed earlier in backend PR #12). Closing.

Resolved in spikersoft-backend PR #46 (merged to `master`). Refactored the two `javascript:S3776` cognitive-complexity functions in `email-verified.html` (`handleMobileControl`, `handleKeyDown`) from 32 down to within the limit via a key→direction lookup + shared `remapDirection`/`applyDirection` helpers. That completes all of #249's scope (the other items — `S2365`, `S3973`, `S131`, `S7761`×2, `S2699` — landed earlier in backend PR #12). Closing.
Sign in to join this conversation.