Description
Inverting if statements can help increase readability and decrease overall code complexity.
Recommendation
Take a look at the following example.
function withdraw(uint256 amount) external nonReentrant {
... if (toWithdraw > 0) {<code when toWithdraw > 0>
}
emit Withdraw(user, totalWithdrawAvaxAmount);
}It can be replaced by
function withdraw(uint256 amount) external nonReentrant {
... emit Withdraw(user, totalWithdrawAvaxAmount);
if (toWithdraw <= 0) return;<code when toWithdraw > 0> }
Status
Currently being reviewed by the team.