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 ruleP1stack specificStack: swift
swiftenumswitchexhaustiveness
Switch enums exhaustively instead of a catch-all default
Handle each enum case explicitly (no default) so adding a case forces a compile error where it must be handled.
PR: mobile-canon-2026-06Created: Jul 5, 2026
Bad example
Old codeswift
| 1 | switch state { case .loading: a(); default: b() } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codeswift
| 1 | switch state { case .loading: a(); case .loaded: b(); case .failed: c() } |
Explanation (EN)
Objašnjenje (HR)