Commit 7e98bab
authored
fix: 15 code quality issues — generics, types, locale, dead code, naming (#118)
## Summary
Resolves 15 code-quality issues across 10 files (24 original commits) + 5 follow-up fixes for CI/CI-blocking issues identified by review tools (CodeRabbit, cubic) and CI logs.
### Original PR (commits 1-24)
- 8 atomic type-safety fixes: ActionResult discriminated union, generic dummyDb methods, type-narrow Genkit output via safeParse, i18n locale mapping, generic handleActionError
- 2 utility additions: `getErrorMessage` (safe error extraction), `getZodError` (Zod detection)
- 3 magic-number extractions: `STREAK_MULTIPLIER`, `BONUS_THRESHOLD`, `BASE_XP_PER_WORKOUT`, `XP_PER_COMPLETED_SERIE`, `MS_PER_DAY`, `DAYS_PER_MONTH`
- 4 cleanup commits: `as` cast removal in alunoService, logger.toRecord safe helper, dead placeholder-images files, misleading constant renames
- tsconfig: `noUnusedLocals` + `noUnusedParameters` enabled
### Follow-up fixes (this squash)
| Commit | Issue | Root cause |
|---|---|---|
| fix(actions): add ActionResult<T> | 8 TS2339 (3 client + 5 test) | async-inferred return widened `success: true` literal to `boolean`, broke `if (result.success)` narrowing |
| fix(deps): remove typosquatted 'supabase' | CI Security audit critical | GHSA-x96m-c5fj-q75c flagged unscoped `supabase@^2.92.1` as malware; unused, all Supabase usage is scoped `@supabase/supabase-js` |
| fix(actions): drop broken HistoricoTreinoSchema.parse() | cubic P1 bug I introduced | Zod schema required `exercicios[]` field not present on Prisma model — parse threw on every successful treino finalization |
| fix(actions): dummyDb `as T` cleanup | CodeRabbit MINOR | Redundant `T | null` in `findById<T>` return cast |
| fix(e2e): wrap seed-e2e top-level await in main() | E2E Tests fail | PR commit 9edd2f9 (SonarQube fixes) refactored seed from `.catch().finally()` to `try { await seed() }` — top-level await incompatible with tsx CJS output |
### Verification
- typecheck: 0 errors
- lint: 0 errors, 9 pre-existing warnings (setState-in-effect, unrelated)
- test: 86/86 (13 suites)
- format: clean
- npm audit --audit-level=high: exit 0
- CI: 13/13 checks pass (Quality Gates, Tests & Coverage, SonarCloud, Vercel, E2E, CodeQL, Semgrep ×2, GitGuardian, CodeRabbit, cubic, Analyze JS-TS, Vercel Preview)1 parent 9edd2f9 commit 7e98bab
41 files changed
Lines changed: 2035 additions & 353 deletions
File tree
- .sisyphus
- evidence
- plans
- docs
- superpowers/plans
- prisma
- src
- ai
- flows
- __tests__
- app
- actions
- aluno/meus-treinos
- dashboard
- planos
- treinos
- __tests__
- components
- dashboard/alunos
- providers
- hooks
- lib
- __tests__
- actions
- services
- utils/supabase
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Whitespace-only changes.
0 commit comments