Omniscia Tangible Audit
RentManager Code Style Findings
RentManager Code Style Findings
RMR-01C: Redundant Separation of Declaration & Assignment
Type | Severity | Location |
---|---|---|
Code Style | RentManager.sol:L413, L415 |
Description:
The referenced statements will first declare a storage
variable and assign to it later redundantly.
Example:
413RentInfo storage rent;414
415rent = rentInfo[tokenId];
Recommendation:
We advise the assignment to be performed at its declaration, optimizing the code's style and conciseness.
Alleviation (2ad448279d9e8e4b6edd94bcd2eb22129b6f7357):
The declaration and assignment have been properly re-coupled, increasing the code's legibility.
RMR-02C: Unreachable Code
Type | Severity | Location |
---|---|---|
Gas Optimization | RentManager.sol:L489-L491 |
Description:
The RentManager::_monthLength
function contains unreachable code as it implements an if-else-if
clause with all possible enum values of the DEPOSIT_MONTH
declaration.
Example:
480function _monthLength(DEPOSIT_MONTH month) internal pure returns (uint256) {481 if (month == DEPOSIT_MONTH.DAYS_31) {482 return 31 days;483 } else if (month == DEPOSIT_MONTH.DAYS_30) {484 return 30 days;485 } else if (month == DEPOSIT_MONTH.DAYS_28) {486 return 28 days;487 } else if (month == DEPOSIT_MONTH.DAYS_29) {488 return 29 days;489 } else {490 revert("Incorrect month");491 }492}
Recommendation:
We advise the last else
clause that reverts to be omitted and the last case of the else-if
chain to be set to a simple else
as the Solidity compiler prohibits the RentManager::_monthLength
function to be invoked with an enum
value that is not explicitly in the range declared by DEPOSIT_MONTH
.
Alleviation (2ad448279d9e8e4b6edd94bcd2eb22129b6f7357):
The code was instead updated to default to 30 days
rather than being omitted, causing the code to remain unreachable.
As such, we consider this exhibit acknowledged.