Sparkn

CodeFox Inc.
DeFiFoundryProxy
15,000 USDC
View results
Submission Details
Severity: low

Unused Variable percentagesLength

Summary

The variable percentagesLength is declared within the _distribute function but is never used in the function's logic. This unused variable increases code complexity and can confuse developers and auditors.

Vulnerability Details

The variable percentagesLength is initialized to store the length of the percentages array, but it is not referenced or used anywhere within the _distribute function.

uint256 percentagesLength = percentages.length;

Impact

The presence of an unused variable can lead to confusion and make the code less readable. It might also mislead developers into thinking that the variable has a functional role in the code logic, potentially leading to incorrect modifications or assumptions.

Tools Used

Manual

Recommendations

Remove the declaration of the percentagesLength variable since it is not being used. Keeping the code clean and removing unnecessary variables helps improve readability and reduces the chance of confusion.

Remove the line:

uint256 percentagesLength = percentages.length;

After removal, the _distribute function should look like this:

function _distribute(address token, address[] memory winners, uint256[] memory percentages, bytes memory data)
internal
{
// ... existing code ...
// winners and percentages input check
if (winners.length == 0 || winners.length != percentages.length) revert Distributor__MismatchedArrays();
uint256 totalPercentage;
for (uint256 i; i < percentages.length;) {
totalPercentage += percentages[i];
unchecked {
++i;
}
}
// ... rest of the code ...
}

By removing the unused variable, you improve the code's clarity and maintainability.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.