Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Return the best available data instead of null when you can
Preserve valid partial data using an explicit domain contract; never fabricate a value merely to avoid null.
Bad example
| 1 | const market = marketplaces.find((m) => m.insref === instrument.marketplace); |
| 2 | if (!market) { |
| 3 | return null; |
| 4 | } |
Explanation (EN)
Discarding independently valid data may unnecessarily remove useful information, but a fallback must remain truthful.
Objašnjenje (HR)
Good example
| 1 | const market = marketplaces.find((m) => m.insref === instrument.marketplace); |
| 2 | if (!market) { |
| 3 | return lastUpdated; // still return useful info |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)
Notes (EN)
Return partial or fallback data only when the domain defines its meaning and consumers can distinguish uncertainty where it matters.
Exceptions / Tradeoffs (EN)
Do not replace an unknown timestamp, financial value or required fact with now or another convenient value. Preserve null or an explicit unavailable result when no valid substitute exists.