fix: N-09, Unexplained and unused constants #3909
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Throughout the OptimisticGovernor contract, to check if a proposal has been approved
by the Optimistic Oracle the literal value int256 1e18 is used, where 1e18 signifies that a
proposal was not rejected by the Optimistic Oracle.
Similarly, in the update to the OptimisticOracle contract the function proposedPrice
uses a magic value type(int256).min to indicate that an event-based proposal cannot be
resolved, because the event has not yet taken place.
Lastly, in the OptimisticOracle contract the MAX_ADDED_ANCILLARY_DATA constant is
declared on line 129. On the next line the constant should be used, but instead the value of the
constant is used directly to derive another constant.
To improve the overall readability of the codebase and to facilitate refactoring, consider
defining a constant for every literal or magic value used, giving it a clear and self-explanatory
name, and then using it in place of literal values. Also consider adding an inline comment
explaining how literal values were calculated or why they were chosen.
Summary
Fixed these issues.
Testing
Check a box to describe how you tested these changes and list the steps for reviewers to test.
Issue(s)
N/A