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: general
control-flowcorrectnessreadability
Order numeric threshold branches so every range is reachable
Sort range/threshold conditions monotonically and make boundaries contiguous so no branch is unreachable and no input falls through to an unintended default.
PR: hegnar-ws · org-mining-hist-2026-06Created: Jun 18, 2026
Bad example
Old codetypescript
| 1 | if (val > 90) return 100; |
| 2 | if (val < 20) return 0; |
| 3 | if (val > 50 && val < 80) return mid; // boundary gaps + ordering hazard |
| 4 | if (val > 80) return high; // unreachable after the >90 check pattern |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (val > 90) return 100; |
| 2 | if (val > 80) return high; |
| 3 | if (val >= 50) return mid; |
| 4 | if (val >= 20) return low; |
| 5 | return 0; |
Explanation (EN)
Objašnjenje (HR)