Why this matters
Reduces unnecessary work and clarifies intent.
Avoid re-checking loop-invariant conditions inside iterations; lift them out.
Reduces unnecessary work and clarifies intent.
Side-by-side examples engineers can pattern-match during review.
for (Item i: items) { if (threshold > 0) { /* heavy */ } }if (threshold > 0) {
for (Item i: items) { /* heavy */ }
}if(flag) inside loopif(flag) { loop }From the same buckets as this rule.
All static JS/CSS/font/image files MUST use content-hashed filenames (e.g., app.9c1a7b.js) and be served with "Cache-Control: public, max-age=31536000, immutable". HTML and other non-fingerprinted documents MUST be served with "Cache-Control: no-cache" (or equivalent) to enable conditional revalidation.