Files
SubMiner/backlog/tasks/task-27.6 - Add-structural-quality-gates-for-file-size-and-complexity.md
2026-02-13 18:29:17 -08:00

2.1 KiB

id, title, status, assignee, created_date, updated_date, labels, dependencies, parent_task_id, priority
id title status assignee created_date updated_date labels dependencies parent_task_id priority
TASK-27.6 Add structural quality gates for file size and complexity To Do
architect
2026-02-13 17:13 2026-02-13 21:19
owner:architect
owner:backend
owner:frontend
TASK-27.1
TASK-27.2
TASK-27.3
TASK-27.4
TASK-27.5
TASK-27 medium

Description

Add automated safeguards so oversized/complex files are caught early and refactor progress is measurable.

Acceptance Criteria

  • #1 Extend check-main-lines gate script to accept any file path and apply it to: src/main.ts, src/anki-integration.ts (or src/anki-integration/index.ts), src/core/services/mpv-service.ts, src/renderer/positioning.ts, src/config/service.ts.
  • #2 Define per-file thresholds (suggested: 400 LOC default, 600 for config/service.ts, justified exceptions documented in the script).
  • #3 Add ESLint complexity rule (or lightweight proxy) with per-directory thresholds — at minimum for src/core/services/ and src/anki-integration/.
  • #4 Create a clear exception process for justified threshold breaks: comment in code with expiration date and owner.
  • #5 Document thresholds in docs/structure-roadmap.md.
  • #6 Clarify enforcement: local-only (npm script) or CI-enforced. If CI, add to the CI pipeline config.

Implementation Notes

Review Additions

Original task omitted anki-integration.ts from the gated file list — it's the largest file at 2,679 LOC and the primary target of TASK-27.3. Added to AC#1.

The existing check-main-lines.sh is a simple wc -l check. Consider augmenting with:

  • ESLint complexity rule for cyclomatic complexity
  • Method count per file (proxy for cohesion)
  • Import count per file (proxy for coupling)

Raw line count is better than nothing but doesn't catch files that are long because of well-structured, low-complexity code (like config/definitions.ts at 479 LOC which is just defaults).