Rules Hub
Code Ruleset
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
Always use braces for control flow blocks
Use braced blocks for if/for/while to prevent accidental logic bugs.
Bad example
| 1 | if (isReady) |
| 2 | doWork(); |
| 3 | log('done'); |
Explanation (EN)
Only doWork is conditional; later edits can obscure that boundary.
Objašnjenje (HR)
Uvjet se odnosi samo na doWork; kasnije izmjene lako prikriju tu granicu.
Good example
| 1 | if (isReady) { |
| 2 | doWork(); |
| 3 | } |
| 4 | log('done'); |
Explanation (EN)
Braces clarify the controlled statement without changing when the log runs.
Objašnjenje (HR)
Zagrade jasno ograničavaju uvjetnu naredbu bez promjene trenutka logiranja.
Notes (EN)
When changing control flow, use braces to make the exact controlled statements visible and preserve the original sequence of side effects.
Bilješke (HR)
Pri promjeni toka kontrole koristi vitičaste zagrade kako bi obuhvaćene naredbe bile jasne i izvorni redoslijed nuspojava ostao sačuvan.
Exceptions / Tradeoffs (EN)
Follow a documented single-line guard convention where allowed; adding braces must not accidentally pull subsequent statements into the branch.