From a262674fac68fb306495772b711e917b0ac57ebc Mon Sep 17 00:00:00 2001 From: Sarthak Agrawal Date: Sat, 15 Aug 2026 17:48:45 +0530 Subject: [PATCH] chore: reduce code-health baseline debt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix all 19 TypeScript format violations (biome format) - Extract routePose helper from server route() to reduce CCN 17→13 - Extract drawArm helper from drawSkeleton to reduce CCN 16→10 - Move hostFrom after Room class to fix lizard misparse (CCN 17→4, length 192→7) - Extract shared roundRect + distPointToSegment into games/canvas-utils.ts to eliminate cross-game duplication - Lower ratcheted baselines: format 19→0, complexity violations 6→3, maxLength 189→180, duplication clones 7→5, duplicatedLines 102→65, percentage 0.8814→0.5543 Closes #26 --- scripts/check-code-health.mjs | 12 ++-- scripts/check-landing.mjs | 80 +++++++++++++++-------- server/src/server.ts | 70 ++++++++++++++------ web/src/app/main.ts | 3 +- web/src/app/overlay.ts | 10 ++- web/src/games/canvas-utils.ts | 39 ++++++++++++ web/src/games/motion-maker/index.ts | 99 ++++++++++++++--------------- web/src/games/reach-dodge/index.ts | 22 +------ web/src/games/slice/index.ts | 68 ++++++++++++-------- web/src/sdk/bridge.ts | 2 +- web/src/sdk/calibration.ts | 5 +- web/src/sdk/controller.ts | 10 +-- web/src/sdk/diagnostics.ts | 2 +- web/src/sdk/game.ts | 2 +- web/src/sdk/index.ts | 17 +++-- web/src/sdk/keyboard-debug.ts | 61 ++++++++++++++---- web/src/sdk/recording.ts | 12 ++-- web/src/sdk/room.ts | 15 +++-- web/src/sdk/skeleton.ts | 52 +++++++++------ web/src/sdk/types.ts | 2 +- web/src/sdk/webcam.ts | 35 +++++++--- 21 files changed, 401 insertions(+), 217 deletions(-) create mode 100644 web/src/games/canvas-utils.ts diff --git a/scripts/check-code-health.mjs b/scripts/check-code-health.mjs index 6516d2f..45f55b6 100644 --- a/scripts/check-code-health.mjs +++ b/scripts/check-code-health.mjs @@ -101,7 +101,7 @@ function checkFormat() { const observed = { files: report.summary.errors }; log(`TypeScript format debt: ${observed.files} files.`); // Ratcheted legacy debt: https://github.com/Significant-Hobbies/motion/issues/26 - failRegressions("TypeScript format", observed, { files: 19 }); + failRegressions("TypeScript format", observed, { files: 0 }); } function checkCoverage() { @@ -168,9 +168,9 @@ function checkComplexity() { ); // Ratcheted legacy debt: https://github.com/Significant-Hobbies/motion/issues/26 failRegressions("Complexity", observed, { - violations: 6, + violations: 3, maxCcn: 22, - maxLength: 189, + maxLength: 180, maxParams: 7, }); } @@ -208,9 +208,9 @@ function checkDuplication() { ); // Ratcheted legacy debt: https://github.com/Significant-Hobbies/motion/issues/26 failRegressions("Duplication", observed, { - clones: 7, - duplicatedLines: 102, - percentage: 0.8814379536812997, + clones: 5, + duplicatedLines: 65, + percentage: 0.5543237250554324, }); } diff --git a/scripts/check-landing.mjs b/scripts/check-landing.mjs index 1fac9a6..9135e47 100644 --- a/scripts/check-landing.mjs +++ b/scripts/check-landing.mjs @@ -37,22 +37,24 @@ const [ ai, sourceLogo, publicLogo, -] = - await Promise.all([ - readFile(path.join(landing, "index.html"), "utf8"), - readFile(path.join(landing, "changelog.html"), "utf8"), - readFile(path.join(landing, "privacy.html"), "utf8"), - readFile(path.join(landing, "styles.css"), "utf8"), - readFile(path.join(landing, "llms.txt"), "utf8"), - readFile(path.join(landing, "index.md"), "utf8"), - readFile(path.join(landing, "_redirects"), "utf8"), - readFile(path.join(landing, "sitemap.xml"), "utf8"), - readFile(path.join(landing, "api/ai.json"), "utf8").then(JSON.parse), - readFile(path.join(root, "web/public/motion-logo.png")), - readFile(path.join(landing, "assets/motion-logo.png")), - ]); +] = await Promise.all([ + readFile(path.join(landing, "index.html"), "utf8"), + readFile(path.join(landing, "changelog.html"), "utf8"), + readFile(path.join(landing, "privacy.html"), "utf8"), + readFile(path.join(landing, "styles.css"), "utf8"), + readFile(path.join(landing, "llms.txt"), "utf8"), + readFile(path.join(landing, "index.md"), "utf8"), + readFile(path.join(landing, "_redirects"), "utf8"), + readFile(path.join(landing, "sitemap.xml"), "utf8"), + readFile(path.join(landing, "api/ai.json"), "utf8").then(JSON.parse), + readFile(path.join(root, "web/public/motion-logo.png")), + readFile(path.join(landing, "assets/motion-logo.png")), +]); -assert.match(html, /Changelog — Motion<\/title>/); assert.equal((changelog.match(/)/g) ?? []).length, 1); -assert.equal((changelog.match(/