President Elector

First Flight #24
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

Hardcoded Constants Without Explanation

Description: The RankedChoice contract includes hardcoded constants, such as MAX_CANDIDATES and i_presidentalDuration, without any accompanying explanation or rationale. This can make it difficult for others to understand the reasoning behind these values and adjust them if necessary.

Impact:

  • Lack of Clarity: Without explanations, it is unclear why certain values were chosen, which can lead to confusion or incorrect assumptions about the contract's behavior.

  • Difficulty in Maintenance: Future developers may struggle to modify or extend the contract if they do not understand the purpose of these constants.

  • Potential Misconfiguration: Hardcoded values may not be suitable for all use cases, and without clear documentation, they may be incorrectly configured.

Proof of Concept: The contract includes hardcoded constants without explanation:

uint256 private constant MAX_CANDIDATES = 10;
uint256 private immutable i_presidentalDuration = 1460 days;

Recommended Mitigation:

  • Add Comments to Explain Constants: Provide comments explaining the purpose and rationale behind each constant value.

  • Consider Configurability: If appropriate, allow these values to be configurable at deployment or through governance mechanisms to accommodate different use cases.

  • Document Assumptions: Clearly document any assumptions or constraints related to these constants to guide future developers and users.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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