wise-foundation / lending-audit

5 stars 4 forks source link

[MHR-01S] Literal Equality of `bool` Variables #100

Open vm06007 opened 1 year ago

vm06007 commented 1 year ago

MHR-01S: Literal Equality of bool Variables

Type Severity Location
Gas Optimization MainHelper.sol:L501, L730, L783, L1016

Description:

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

Example:

if (hashMap[hashData] == 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.