The giveReview function includes a check on reviewCount[_student] to limit the number of reviews a student can receive. However, this variable is never updated in the function, rendering the check ineffective. Additionally, due to an existing time-based constraint, the reviewCount variable appears redundant and may be safely removed.
The giveReview function is implemented as follows:
In this function:
Line 281 checks that reviewCount[_student] < 5.
However, reviewCount[_student] is never incremented or updated.
As a result, this check has no effect and does not prevent a student from receiving more than 5 reviews.
Moreover, the function already enforces a time-based restriction:
This ensures that reviews can only be submitted at intervals defined by reviewTime. Combined with a bounded session duration (e.g., via sessionEnd), the total number of reviews per student is inherently limited, making the reviewCount variable redundant.
Logical Inconsistency: A variable is checked without being updated, leading to dead code.
Wasted Storage: The reviewCount mapping consumes unnecessary storage and gas without contributing functional value.
Developer Confusion: Future developers may assume the check is effective and misinterpret the contract's behavior.
Manual Code Review
Option 1: Keep the review count logic and fix the bug. If the goal is to enforce a maximum number of reviews per student (independent of time), the contract should increment reviewCount[_student] after a review is given:
Place this after the review is applied and before emitting the event.
Option 2: Remove the reviewCount logic entirely. If the intention is to limit reviews based solely on time constraints, remove the reviewCount check and mapping to reduce contract complexity and save gas.
`reviewCount` for students is not updated after each review session
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.