openzeppelin-contracts icon indicating copy to clipboard operation
openzeppelin-contracts copied to clipboard

Create custom linting rules for conventions

Open frangio opened this issue 3 years ago • 1 comments

There are a few things that we should be checking for automatically. We should create custom linter rules for them. We are currently using Solhint as a linter and it has the ability to define custom rules. Solhint seems to be mostly unmaintained and if it continues like that we might want to switch to some other linter, but unfortunately there seems to be no alternative at the moment. (Although one alternative could be Slither, which we're already using as well.) The effort of writing custom rules for Solhint is probably small enough that it's still worth doing even if we switch to some other linter soon.

Here we can collect the different rules that we should have:

  • Check all state variables are private.
  • Check there are no "external virtual" functions (they can't be overridden and call super).
  • Check all internal and private variables and functions are prefixed with underscore.

frangio avatar Jan 03 '23 17:01 frangio

Hello,

I published a solhint plugin for this request at: https://www.npmjs.com/package/solhint-plugin-ozcontracts

You can check the code at: https://github.com/lhemerly/solhint-plugin-ozcontracts

Please let me know if you need any changes

lhemerly avatar Mar 21 '23 04:03 lhemerly