protofire/solhint

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

a-t-0 opened this issue · 3 comments

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"?

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

this feature would help: #359

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