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).
mobile ruleP2stack specificStack: swift
swiftenumcaseiterabledry
Iterate an enum with CaseIterable.allCases, not a hardcoded list
When an enum is CaseIterable, use allCases (and rawValue) instead of manually listing cases, so adding a case doesn't require editing every list.
PR: mobile-mining-2026-06Created: Jul 5, 2026
Bad example
Old codeswift
| 1 | let fonts = [Font.title, Font.body, Font.caption] |
Explanation (EN)
Objašnjenje (HR)
Good example
New codeswift
| 1 | let fonts = Font.allCases // enum Font: CaseIterable |
Explanation (EN)
Objašnjenje (HR)