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).
Don't override an existing column via a join without a documented reason
If the base table already has the column, an extra join that overrides it is either redundant or needs a comment explaining the data-quality reason.
Bad example
| 1 | // corporateActions already has a tradecurrency column, |
| 2 | // but we silently override it from a joined table |
| 3 | db.select({ |
| 4 | ...getTableColumns(corporateActions), |
| 5 | tradecurrency: instruments.tradecurrency, |
| 6 | }) |
| 7 | .from(corporateActions) |
| 8 | .leftJoin(instruments, eq(corporateActions.insref, instruments.insref)); |
Explanation (EN)
Overriding a column the base table already provides looks like a mistake. A reviewer can't tell whether the join is redundant or there's a real reason, so they'll either flag it or revert it.
Objašnjenje (HR)
Prepisivanje stupca koji bazna tablica vec ima izgleda kao greska. Recenzent ne moze znati je li join suvisan ili postoji pravi razlog, pa ce ga ili oznaciti ili vratiti.
Good example
| 1 | // corporateActions.tradecurrency is almost always empty in source data, |
| 2 | // so we authoritatively take it from instruments. |
| 3 | db.select({ |
| 4 | ...getTableColumns(corporateActions), |
| 5 | tradecurrency: instruments.tradecurrency, |
| 6 | }) |
| 7 | .from(corporateActions) |
| 8 | .leftJoin(instruments, eq(corporateActions.insref, instruments.insref)); |
Explanation (EN)
If the override is intentional, a one-line comment stating the data-quality reason turns a 'why is this here?' into a deliberate decision. If there is no such reason, drop the join and use the base column.
Objašnjenje (HR)
Ako je prepisivanje namjerno, komentar od jedne linije s razlogom (kvaliteta podataka) pretvara 'zasto je ovo tu?' u svjesnu odluku. Ako razloga nema, ukloni join i koristi stupac bazne tablice.
Exceptions / Tradeoffs (EN)
A documented data-quality reason (base column unreliable/empty) is a valid justification — just write it down.
Iznimke / Tradeoffi (HR)
Dokumentiran razlog kvalitete podataka (bazni stupac nepouzdan/prazan) je valjano opravdanje — samo ga zapisi.