Skip to content
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

How to apply the foundry-test-functions rule only to test files? #577

Closed
a-t-0 opened this issue Apr 21, 2024 · 3 comments
Closed

How to apply the foundry-test-functions rule only to test files? #577

a-t-0 opened this issue Apr 21, 2024 · 3 comments

Comments

@a-t-0
Copy link

a-t-0 commented Apr 21, 2024

Thank you for your awesome work on creating and sharing this linter, and for implementing the auto-fix with no-prompt functionality!

Context

While running solhint.json with content:

{
  "extends": [
    "solhint:all"
  ],
  "plugins": []
}

and .pre-commit-config.yaml configuration:

- id: solhint
       name: Solidity style guide compliance.
       entry: solhint
       language: node
       verbose: true
       files: ^(contracts/|interfaces/|libraries/|src/|script/|test/)
       args:
         [
           "--fix", # Automatically fix those issues that can be auto-fixed.
           "--noPrompt", # Do not ask for backup before fix.
         ]

I notice that the foundry-test-functions rule is triggered on non-test files:

src/Helper.sol
8:3 warning Function computeCumRemainingInvestorReturn() must match Foundry test naming convention foundry-test-functions

Question

Would you perhaps be able to enlighten me on the following matter:
How could I tell solhint to only apply the foundry-test-functions rule to all .sol files in designated test folder(s)? Is it for example possible to override that rule to only apply to test/* in the solhint.json file? Or is there a CLI arg that allows for specification of the test files, such that solhint automatically applies that rule "intelligently"?

@dbale-altoros
Copy link
Collaborator

dbale-altoros commented Apr 25, 2024

hello @a-t-0 thanks a lot for posting!
sorry the delay... team is quite busy

you're right... right now you cannot do what you ask
I mean... i can think of a work around which I don't like much... but maybe it solves your issue
As you can see in the rules explanation, this rule should be executed in a separate folder
So you can make a json file for all the other rules using the recommended setting instead if the all and add manually all the others you need without this foundry one...
And then execute it again only for this rule in a separate folder...

This is not the best solution... we need to do a better one for this rule like specifying the folder like you said... but for now, I cannot think right now a better approach that the one I mentioned

@cruzdanilo
Copy link
Contributor

this feature would help: #359

@a-t-0
Copy link
Author

a-t-0 commented May 1, 2024

@dbale-altoros Thank you for your solution-oriented suggestion! @cruzdanilo thank you, I agree that would be a valuable feature.

@a-t-0 a-t-0 closed this as completed May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants