The getOrderDetailsString function is designed to return a formatted string with order details including a status field that reflects the current state of the order.
The function performs redundant status variable assignments by first setting the status using a ternary operator, then immediately overwriting it with an if-else chain that performs identical checks, resulting in unnecessary gas consumption.
Likelihood:
This inefficiency occurs every time getOrderDetailsString is called, affecting all users querying order details
The redundant operations execute consistently across all function calls without any conditional bypass
Impact:
Unnecessary gas consumption for all users calling the function
Reduced code maintainability due to duplicate logic that can lead to inconsistencies
Performance degradation from redundant computations and memory assignments
This analysis shows how the initial ternary assignment is completely overwritten by the subsequent conditional logic:
Remove the redundant initial assignment and use only the if-else logic to eliminate unnecessary gas consumption:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.