Rules Hub
Coding Rules Library
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Remove dead fallback and recovery logic
Fallbacks, retries, and recovery branches must correspond to a real failure mode in the current implementation, not to a past or assumed one.
Bad example
| 1 | if (response.statusCode === 401) { |
| 2 | const refetchEvent = new CustomEvent('refetchToken'); |
| 3 | window.dispatchEvent(refetchEvent); |
| 4 | return; |
| 5 | } |
| 6 |
|
| 7 | return showSnackbar({ message: 'Noe gikk galt' }); |
Explanation (EN)
The branch looks thoughtful, but it is dead if the request no longer depends on a refreshable token. Dead recovery code increases complexity and misleads reviewers about the real runtime behavior.
Objašnjenje (HR)
Grana izgleda promisljenom, ali je mrtva ako request vise ne ovisi o tokenu koji se moze refreshati. Dead recovery kod povecava slozenost i zavarava reviewere o stvarnom runtime ponasanju.
Good example
| 1 | if (!response.payload) { |
| 2 | showSnackbar({ message: 'Kunne ikke laste transaksjoner', severity: 'error' }); |
| 3 | setIsError(true); |
| 4 | return; |
| 5 | } |
Explanation (EN)
The error path matches the actual runtime behavior. Recovery logic is added only when the system really supports and needs it.
Objašnjenje (HR)
Error path odgovara stvarnom runtime ponasanju. Recovery logika se dodaje samo kada je sustav stvarno podrzava i treba.
Notes (EN)
When implementation assumptions change, revisit related retry, refresh, fallback, and normalization branches in the same PR.
Bilješke (HR)
Kada se promijene pretpostavke implementacije, u istom PR-u ponovno provjeri retry, refresh, fallback i normalization grane.
Exceptions / Tradeoffs (EN)
Keep dormant recovery logic only if it is intentionally part of an approved near-term rollout and clearly documented as such.
Iznimke / Tradeoffi (HR)
Zadrzi dormant recovery logiku samo ako je namjerno dio odobrenog kratkorocnog roll-outa i jasno je dokumentirana.