Open smartcontracts opened 3 days ago
Sounds good to me, I'll take this one
Awesome, thank you!
I mentioned it in the design-doc for custom errors, but do we actually just want a semgrep rule to blanket outlaw require
and then use assertEq
and assert
in tests/scripts
I mentioned it in the design-doc for custom errors, but do we actually just want a semgrep rule to blanket outlaw
require
and then useassertEq
andassert
in tests/scripts
Yes
We're moving most of the codebase to custom error messages but there will still be plenty of places like scripts and tests where
require
gets used instead.@jsvisa has a nice PR open (#12702) that does some of the work to make sure that all instances of
require
have a corresponding error message.We should have a semgrep rule that enforces this condition so that we don't end up adding new
require
statements that don't have messages.Tasks for this issue are:
require(..., $MSG)
When adding the semgrep rule, something along the lines of the following should work:
Tests for the semgrep rule should be added in
semgrep/sol-rules.t.sol
.For the sake of keeping PRs clean, I generally recommend creating the rule + tests in one PR while excluding files/folders where the rule is violated so that no changes to the contracts are actually required. Afterwards, a second PR can remove the exclusions and fix all of the violations.