wise-foundation / lending-audit

5 stars 4 forks source link

[OHR-06C] Redundant Conditional Evaluation #78

Open vm06007 opened 1 year ago

vm06007 commented 1 year ago

OHR-06C: Redundant Conditional Evaluation

Type Severity Location
Gas Optimization OracleHelper.sol:L134

Description:

The referenced else clause will validate that currentDiff < current Biggest in an AND (&&) clause with its main condition redundantly as the inverse of the condition is evaluated in the if clause of the overall statement.

Example:

if (currentDiff >= currentBiggest) {

    currentSecondBiggest = currentBiggest;
    currentBiggest = currentDiff;

} else if (currentDiff > currentSecondBiggest && currentDiff < currentBiggest) {
    currentSecondBiggest = currentDiff;
}

Recommendation:

We advise the currentDiff < currentBiggest condition to be omitted as it is implied by the if clause's failure.

vm06007 commented 1 year ago

addressed in: https://github.com/wise-foundation/lending-audit/pull/77