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 ruleP1universalStack: universal
single-responsibilityrefactoringdry
Split functions that bundle unrelated responsibilities
When a single function does two unrelated things, split it so duplicated logic becomes obvious and each piece is reusable.
PR: hegnar-ws · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | function getMillistreamIds(webcasts) { |
| 2 | // fetches webcasts AND extracts ids AND dedupes - three jobs |
| 3 | const list = fetchWebcasts(); |
| 4 | return list.map((w) => w.id); |
| 5 | } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | function extractIds(webcasts) { |
| 2 | return [...new Set(webcasts.map((w) => w.id))]; |
| 3 | } |
| 4 | // fetching lives in its own function/caller |
Explanation (EN)
Objašnjenje (HR)