wise-foundation / lending-audit

5 stars 4 forks source link

[WLL-01S] Literal Equality of `bool` Variables #99

Open vm06007 opened 1 year ago

vm06007 commented 1 year ago

WLL-01S: Literal Equality of bool Variables

Type Severity Location
Gas Optimization WiseLowLevelHelper.sol:L34, L440

Description:

The linked bool comparisons are performed between variables and bool literals.

Example:

if (_byPassCase(msg.sender) == true) {

Recommendation:

We advise each bool variable to be utilized directly either in its negated (!) or original form.

vm06007 commented 1 year ago

Team would prefer to leave boolean comparison with == true in this case, as it simplifies reading and less likely to be lost as comparison value. Oppose not using anything.

This also in our opinion makes it easier to work with the code if condition needs to be negated or flipped, we can simplify change false to true or other way around as oppose to adding or deleting ! sign in front of the expression making more vulnerable to accidental loss of the character and misinterpretation of the logic intended.