Why this matters
Reduces maintenance cost and prevents logical drift.
Duplicate sequences of statements must be extracted into a named function or utility.
Reduces maintenance cost and prevents logical drift.
Side-by-side examples engineers can pattern-match during review.
total += item.price * item.qty; // repeated in multiple placesconst lineTotal=i=>i.price*i.qty; const total=items.reduce((a,i)=>a+lineTotal(i),0);x.price*x.qty // repeatedfunction lineTotal(i){ return i.price*i.qty }From the same buckets as this rule.