From 77563d1b60a091391d18a574a8d5463840c3ed45 Mon Sep 17 00:00:00 2001 From: arielpetit Date: Tue, 28 Jul 2026 11:44:23 +0100 Subject: [PATCH] fix(): Fix Undefined Crash --- lib/scoring/engine.ts | 8 ++- package-lock.json | 132 ------------------------------------------ tests/engine.test.ts | 14 +++++ 3 files changed, 19 insertions(+), 135 deletions(-) diff --git a/lib/scoring/engine.ts b/lib/scoring/engine.ts index 68ef9c5..dc018a1 100644 --- a/lib/scoring/engine.ts +++ b/lib/scoring/engine.ts @@ -179,9 +179,11 @@ export function buildCard(s: Signals): Card { // `finish` directly rather than via pickFinish: any overall >= 90 would // otherwise auto-promote to ICON (and flip club/archetype), hijacking the look. const founder = FOUNDERS[s.login.toLowerCase()]; - const overall = founder - ? FOUNDER_OVERALL[s.login.toLowerCase()] - : clamp(baseOVR + Math.round(K.legacy.bonusMax * L), 1, 99); + const founderOverall = founder ? FOUNDER_OVERALL[s.login.toLowerCase()] : undefined; + const overall = + founderOverall !== undefined + ? clamp(founderOverall, 1, 99) + : clamp(baseOVR + Math.round(K.legacy.bonusMax * L), 1, 99); const finish: Finish = founder ? "founder" : pickFinish(overall, L, s.recent_spike, s.login); const archetype = founder ? { name: "Founder", blurb: "co-founder of GitFut — they built the very scout reading this card" } diff --git a/package-lock.json b/package-lock.json index 0442068..ea8e3da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -620,9 +620,6 @@ "cpu": [ "arm" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -639,9 +636,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -658,9 +652,6 @@ "cpu": [ "ppc64" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -677,9 +668,6 @@ "cpu": [ "riscv64" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -696,9 +684,6 @@ "cpu": [ "s390x" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -715,9 +700,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -734,9 +716,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -753,9 +732,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "LGPL-3.0-or-later", "optional": true, "os": [ @@ -772,9 +748,6 @@ "cpu": [ "arm" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -797,9 +770,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -822,9 +792,6 @@ "cpu": [ "ppc64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -847,9 +814,6 @@ "cpu": [ "riscv64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -872,9 +836,6 @@ "cpu": [ "s390x" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -897,9 +858,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -922,9 +880,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -947,9 +902,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "Apache-2.0", "optional": true, "os": [ @@ -1171,9 +1123,6 @@ "cpu": [ "arm64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1190,9 +1139,6 @@ "cpu": [ "arm64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1209,9 +1155,6 @@ "cpu": [ "x64" ], - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1228,9 +1171,6 @@ "cpu": [ "x64" ], - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1423,9 +1363,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1443,9 +1380,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1463,9 +1397,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1483,9 +1414,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1503,9 +1431,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1523,9 +1448,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1791,9 +1713,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1811,9 +1730,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -1831,9 +1747,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -1851,9 +1764,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2422,9 +2332,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2439,9 +2346,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2456,9 +2360,6 @@ "loong64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2473,9 +2374,6 @@ "loong64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2490,9 +2388,6 @@ "ppc64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2507,9 +2402,6 @@ "riscv64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2524,9 +2416,6 @@ "riscv64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -2541,9 +2430,6 @@ "s390x" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2558,9 +2444,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MIT", "optional": true, "os": [ @@ -2575,9 +2458,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MIT", "optional": true, "os": [ @@ -5487,9 +5367,6 @@ "arm64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -5511,9 +5388,6 @@ "arm64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -5535,9 +5409,6 @@ "x64" ], "dev": true, - "libc": [ - "glibc" - ], "license": "MPL-2.0", "optional": true, "os": [ @@ -5559,9 +5430,6 @@ "x64" ], "dev": true, - "libc": [ - "musl" - ], "license": "MPL-2.0", "optional": true, "os": [ diff --git a/tests/engine.test.ts b/tests/engine.test.ts index 8c54101..96c0f8b 100644 --- a/tests/engine.test.ts +++ b/tests/engine.test.ts @@ -68,4 +68,18 @@ describe("buildCard — founder overrides", () => { expect(card.finish).not.toBe("founder"); expect(card.founder).toBeUndefined(); }); + + it("falls back to normal scoring when FOUNDER_OVERALL is missing for a founder login", () => { + const card = buildCard(withLogin("some-random-dev")); + expect(card.overall).toBeDefined(); + expect(card.overall).toBeGreaterThanOrEqual(1); + expect(card.overall).toBeLessThanOrEqual(99); + expect(card.finish).not.toBe("founder"); + }); + + it("clamps founder overall to the 1-99 range", () => { + const card = buildCard(withLogin("younesfdj")); + expect(card.overall).toBeGreaterThanOrEqual(1); + expect(card.overall).toBeLessThanOrEqual(99); + }); });