Replace Inline Code with Function Call

Removes smells
Symptom

Inline code that reproduces what a named function in the codebase already does — a boolean check `candidate >= low && candidate <= high` when `between(value, low, high)` exists.

Goal

When inline code reproduces what a named function already does, the inline copy is replaced by a call.

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 of the same thing drift over time; bug fixes don't propagate; future readers wonder if the inline version is intentionally different.

Tradeoff

If the existing function's name doesn't quite match the local intent, the call site reads as a near-miss; consider Change Function Declaration first.

Relief

One canonical implementation; the name labels the intent; future improvements to the function reach every site that used to inline.

Trap

Replacing inline code with a call to an existing function whose name doesn't quite match — the call site reads as a near-miss instead of as exactly what's happening.