You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Complex expressions become quadratically more difficult as they are expanded. Limiting if statements to simple expressions improves readability, generally, and also causes the code to become more self-documenting (i.e. isActive vs now < expiresAt && now >= activeAt).
Also, due to the nature of JavaScript (i.e. NaN comparisons), it's easy to have false conditions such as now > expires_at == false when bugs have crept in now > NaN == false.
Using named boolean expressions (i.e. isActive) that can easily be negated (i.e. !isActive) improves correctness and security.
The text was updated successfully, but these errors were encountered:
This rule is taken from Zig.
❌ Bad Example
✅ Good Example
Rationale
Complex expressions become quadratically more difficult as they are expanded. Limiting
if
statements to simple expressions improves readability, generally, and also causes the code to become more self-documenting (i.e.isActive
vsnow < expiresAt && now >= activeAt
).Also, due to the nature of JavaScript (i.e.
NaN
comparisons), it's easy to have false conditions such asnow > expires_at == false
when bugs have crept innow > NaN == false
.Using named boolean expressions (i.e.
isActive
) that can easily be negated (i.e.!isActive
) improves correctness and security.The text was updated successfully, but these errors were encountered: