Replace Inline Code with Function Call

Removes smells
Symptom

The agent finds inline code that reproduces the body of a named function elsewhere in the codebase; consistency depends on both implementations staying in sync.

Goal

One canonical implementation the agent loads once and references everywhere; the name labels the intent at every call site.

Before the refactoring

const inRange = candidate >= low && candidate <= high;

After the refactoring

const inRange = between(candidate, low, high);
Example source: Illustrative example written for this site, not a quotation from any source.
Pressure

Two implementations drift over time; the agent verifying changes must update both or risk inconsistency the type checker doesn't catch.

Tradeoff

If the existing function's name doesn't quite match the local intent, the agent reads the call site as a near-miss and must verify the semantic match at every replacement.

Relief

The agent reasons about one definition; future improvements reach every site that used to inline; consistency is enforced by reference.

Trap

Replacing inline code with a call to a poorly-named function smears semantic mismatch across the codebase — the agent must constantly verify that the function's name still describes the local use.