The same setup (logging, validation, metric tick) or follow-up code appears around every call to a function — repeated boilerplate at every call site.
The agent finds the same setup or follow-up code around every call to a function; consistency depends on every caller remembering the pattern.
Setup or follow-up that happens around every call to a function moves inside the function, so the caller's contract shrinks.
The function owns its setup and follow-up; the agent verifies behavior at the function definition instead of auditing every call site.
Before the refactoring
log('start fetch');const data = fetch(url);log('start fetch');const data2 = fetch(url2);
After the refactoring
function fetchLogged(url) {log('start fetch');return fetch(url);}
Every caller must remember the boilerplate; missing it produces inconsistent behavior the function doesn't enforce; updates to the boilerplate touch every caller.
Every caller is a chance to miss the boilerplate or misorder it; the agent verifying consistency must check every site individually.
If the moved statements aren't always wanted, the function grows a flag argument — verify every caller really needs the moved behavior.
If some callers genuinely don't want the moved behavior, the function grows a flag argument and the agent must reason about which mode each caller wants.
One fewer thing to remember at the call site; consistency is enforced by the function's definition, not by convention.
The agent reasons about the function's full contract from its definition; consistency is enforced by the function, not by convention.
Moving statements into a function that some callers don't actually want — the function grows a flag argument to make the moved behavior conditional, which is a worse smell.
Moving statements into a function some callers don't want adds a flag argument the agent must thread through every call site — substitutes one boilerplate for another.