Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP2universalStack: javascript
dryerror-handlingloggingcode-hygiene
Remove duplicate guard/logging blocks within one function
When the same guard (e.g. an if (!response.ok) log) appears twice in one function, keep a single check to avoid duplicate logging and dead branches.
PR: hegnar-forum-web · org-mining-hist-2026-06Created: Jun 20, 2026
Bad example
Old codetypescript
| 1 | if (!response.ok) logger.error('failed'); |
| 2 | // ... |
| 3 | if (!response.ok) logger.error('failed'); // duplicate |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | if (!response.ok) { |
| 2 | logger.error('failed'); |
| 3 | return null; |
| 4 | } |
Explanation (EN)
Objašnjenje (HR)