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).
Keep the base config file valid on its own; overrides add variation, not required pieces
When the base file declares a dependency on something only an override defines, it stops validating standalone and every tool and newcomer that reads it alone breaks. Put whatever the base requires in the base, and leave only the per-environment differences to the overrides.
Bad example
| 1 | # docker-compose.yml |
| 2 | services: |
| 3 | app: |
| 4 | depends_on: [cache] # 'cache' defined only in the per-tenant overrides |
| 5 |
|
| 6 | # docker-compose.a.yml and docker-compose.b.yml each repeat the same 14-line |
| 7 | # cache service and the same volume block |
Explanation (EN)
The base file fails validation on its own, and the duplicated service means every image bump has to be made in two places.
Objašnjenje (HR)
Osnovna datoteka sama ne prolazi provjeru, a udvostruceni servis znaci da se svaka promjena slike mora napraviti na dva mjesta.
Good example
| 1 | # docker-compose.yml - self-contained |
| 2 | services: |
| 3 | app: |
| 4 | depends_on: [cache] |
| 5 | cache: |
| 6 | image: redis:7 |
| 7 | volumes: [cache:/data] |
| 8 | volumes: |
| 9 | cache: |
| 10 |
|
| 11 | # docker-compose.a.yml - only what actually differs |
| 12 | services: |
| 13 | app: |
| 14 | environment: |
| 15 | TENANT: a |
Explanation (EN)
The base validates alone, the shared service exists once, and each override carries only its own difference.
Objašnjenje (HR)
Osnovna datoteka prolazi provjeru sama, dijeljeni servis postoji jednom, a svaki override nosi samo vlastitu razliku.
Notes (EN)
Validating the base file by itself in CI catches this immediately, and the same move usually removes the duplicated block from the overrides.
Bilješke (HR)
Provjera osnovne datoteke same u CI-ju odmah otkriva ovo, a isti potez obicno uklanja i udvostruceni blok iz overridea.