Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: TypeScript
loopscontrol-flowcorrectness
Skip to the next iteration when there is nothing to process
Inside a loop, after logging/handling a missing or filtered-out case, use continue so you don't fall through to processing empty data.
PR: vinify-backend · org-mining-hist-2026-06Created: Jun 19, 2026
Bad example
Old codetypescript
| 1 | for (const product of products) { |
| 2 | const filtered = filter(product); |
| 3 | if (!filtered.length) { |
| 4 | logger.log('no products'); |
| 5 | // falls through and processes empty filtered |
| 6 | } |
| 7 | process(filtered); |
| 8 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | for (const product of products) { |
| 2 | const filtered = filter(product); |
| 3 | if (!filtered.length) { |
| 4 | logger.log('no products'); |
| 5 | continue; |
| 6 | } |
| 7 | process(filtered); |
| 8 | } |
Explanation (EN)
Objašnjenje (HR)