-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rule for test function names #402
Comments
@PaulRBerg you mean a rule to do what ? |
Yes. A rule that would activate the regex above. |
Some thoughts on this. First, I guess the behavior of the new rule should be: "If a (public?) function starts with Second, having some way to only apply the rule for files in a given directory makes a lot of sense, but I'm not sure what's the best way to accomplish it. Possible solutions:
A middle ground would be this: have two solhint files |
Foundry considers only public or external functions tests, so I agree about the public qualifier. I agree that the best way to add support for this rule would be to be able to nested Solhint configurations in folders, but I would smile upon having one of the interim solutions you mentioned (e.g. |
@PaulRBerg Seems like |
@dbale-altoros But yes I think for backward compatibility, it would be helpful to add it in the regex. btw thanks for shipping so many features lately! |
oh, did not know it was supposed to be deprecated |
I read all your comments. For now, to speed up the process and in order to use it, two Rule configuration is as specified in readme Feedback appreciate |
new release this Friday !! |
Just as feedback, I always use the naming scheme |
@pcaversaccio thanks a lot for your feedback, I really appreciate And from what I read... the |
Correct, that's at least how I personally use it.
Also correct, from the docs: |
Thanks again @pcaversaccio What is kind of confusing is that on every foundry doc, there's always an underscore before the description (or function name)... |
Well not only me :), e.g. OpenZeppelin uses the same naming scheme: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/test/utils/math/Math.t.sol |
Of course! |
Ah yes, only
|
THANKS!!! |
Fixed here |
Any updates on this feature? I've just upgraded to the latest Solhint and there are a bunch of rules that I would like activated in
For the full terminal log, see this. |
My repo is not public so can't share it but I use two "solhint:check": "npx solhint -c src/.solhint.json src/**/*.sol && npx solhint -c test/.solhint-tests.json test/**/*.sol",
"solhint:fix": "npx solhint -c src/.solhint.json src/**/*.sol --fix && npx solhint -c test/.solhint-tests.json test/**/*.sol --fix", This does the job for me now. |
@PaulRBerg |
With the advent of Foundry, more and more Solidity projects are now tested in Solidity itself. This has led to the community coalescing around several conventions, such as using the following regex for test function names:
This is recommended in the Best Practices tutorial of the Foundry Book.
Here are a few examples:
test_Description
test_RevertWhen_Condition
testFuzz_Description
testForkFuzz_RevertWhen_Condition
It would be nice if there were a Solhint rule for this - and even nicer if the rule could be configured to apply only to contracts in specific directories (e.g. in
test
).The text was updated successfully, but these errors were encountered: