R209 Keep only checks that take seconds in the commit hooks
Superseded by R250 Keep only checks that take seconds, and no tests, in the commit hooks.
Put only checks that take seconds into a repository’s commit hooks, aiming at no more than 5 seconds for all of them, and leave checks that need a heavy toolchain or outside state to the checks before a push and to CI.
Reason
The hooks run at every commit: slow ones hold up each commit and tempt the author to skip them (Art. III §1(2)). The heavy checks still run before the push and in CI, so none is lost.
Verification
What counts is the total time of all the hooks on a commit of ordinary size, in a checkout where they are installed. The credential scan goes into the hooks before other checks, and scans the staged changes (rule 50). Hooks that pass do not clear a push: the checks the change touches still run before it (rule 53).
Violated when a repository’s commit hooks hold a check that needs a toolchain installed on the spot (compiling the whole project or downloading dependencies, for example) or needs the network or an outside service, or when all the hooks on an ordinary commit take more than 5 seconds time after time.