todo-app/.pre-commit-config.yaml
Krzysztof kuhy Rudnicki 9d2aa1c178 Enforce the 250-line file cap, and split the first four files
Wires the shared gate (~/utils/scripts/check_file_length.sh) into a new
.pre-commit-config.yaml as a local hook, checking only the files in the
commit and failing rather than warning. No baseline, no allowlist.

The repo had a hand-written .git/hooks/pre-commit running two checks;
both are ported verbatim into the config rather than dropped, with the
version bump ordered last so it cannot rewrite pubspec.yaml for a commit
a gate is still about to reject. scripts/install_hooks.sh now installs
pre-commit (and removes the legacy hook) instead of writing its own.

.github/workflows/file-length.yml runs the same check on push, kept
separate from release-apk.yml so an over-long file fails lint rather than
blocking an APK release.

Splits the four cleanest violations, all behaviour-preserving:

  note_template.dart      370 -> 203 + parser (186)
  firebase_backend.dart   308 -> barrel (24) + project/store/client
  port_guard.dart         315 -> 232 + linux_system_probe (100)
  notes_list_screen.dart  698 -> 225 + 5 widget/nav files

Where a file had external callers, the original path stays as a barrel
that re-exports the split parts, so no call site changed.

Verified: 313 tests pass, coverage identical at 99.9% / 1922 lines
(per-file too -- notes_list's 281 covered lines are now 81+75+51+41+22+11),
flutter analyze clean, and a staged 260-line file makes git commit fail.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-14 16:01:24 +02:00

44 lines
1.9 KiB
YAML

# Pre-commit hooks for todo.
#
# This repo previously used a hand-written .git/hooks/pre-commit installed by
# scripts/install_hooks.sh. It moved to the pre-commit framework when the
# 250-line file-length gate was added, so all three checks live in one place
# with one install path. The two pre-existing checks are ported verbatim
# below -- dropping them to add a new gate would trade one silent failure for
# another.
#
# Install with: pre-commit install
# The hooks are `language: system` because they are plain bash/python already
# on this machine; pre-commit must not build an isolated env for them.
repos:
- repo: local
hooks:
# Gate first: a local crdt_sync override left in place makes CI build a
# library this checkout has never tested against, silently and in both
# directions. Blocking the commit is the only thing that prevents it.
- id: no-crdt-sync-override
name: no local crdt_sync dependency_override
entry: scripts/check_no_crdt_sync_override.sh
language: system
files: ^pubspec\.yaml$
# The shared 250-line cap. Checks only the files in the commit, so an
# unrelated commit never breaks; exits 1 rather than warning. No
# baseline and no allowlist -- those are suppressions. The exemption
# list (generated/vendored/data files) lives with the checker in
# ~/utils/file_length/config.py so the gate and the survey cannot
# disagree.
- id: file-length
name: file length <= 250 lines
entry: scripts/check_file_length.sh
language: system
# Version bump LAST: it rewrites pubspec.yaml and `git add`s it, so it
# must not run before a gate that could still reject the commit.
- id: bump-patch-version
name: bump patch version
entry: scripts/bump_patch_version.sh
language: system
pass_filenames: false
always_run: true