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).
fullstack ruleP2universalStack: universal
readabilitycontrol-flowfunctionsclarity
Call a transform only when it would actually change the input
Don't call a function that returns its input unchanged for some flag values; guard at the call site so the function is invoked only when it has work to do.
PR: hegnar-forum-web · org-mining-2026-06Created: Jun 17, 2026
Bad example
Old codets
| 1 | // returns input unchanged when !isMobile |
| 2 | const tabs = reorderTabs(visibleTabs, isMobile); |
Explanation (EN)
Objašnjenje (HR)
Good example
New codets
| 1 | const tabs = isMobile ? reorderTabs(visibleTabs) : visibleTabs; |
Explanation (EN)
Objašnjenje (HR)