duaraghav8 / Ethlint

(Formerly Solium) Code quality & Security Linter for Solidity
https://ethlint.readthedocs.io/en/latest/
MIT License
927 stars 128 forks source link

Make solium less opinionated by default as far as styling is concerned. #159

Closed LefterisJP closed 6 years ago

LefterisJP commented 6 years ago

Hey,

I recently integrated solium to emacs solidity mode. It's great but also rather opinionated. It follows a particular style whoever wrote solidity's read the docs liked (camelcase) and makes anything else appear as errors or warnings.

I know that these can be configured and turned off but it would be better if the user could avoid style suggestions unless requested. I find it annoying to have to disable all style rules. And for my styling rules there is no enforcement. For example I can't enforce snake case.

Examples of opinionated errors:

 warning    FunctionDeclaration must be succeeded by 1 blank line
error      Opening brace must be on a new line immediately after the last modifier.
 error      Opening brace must be on the line after returns declaration

And the last 2 should only have been warnings. There is no error involved. It's a style choice to have the brace like that, and a rather popular one called K&R.

Also this warning is rather off:

 warning    Function "ecrecover": in case of more than 3 arguments, drop each into its own line.

It is not the number of arguments that count but the number of columns they take. Most projects I have worked in always keep arguments in one line, unless the function call exceeds the XX column limit (with XX being either 80 or 100) in which case yes indeed each argument is split into its own line.

I suggest having style choices grouped into something like the different indentation styles seen here and allow the user to choose one and then fine-tune through specific options. But not only support the camelcase style that is supported now.

If you want to have a style linter make it one that can be used by all groups, not only one particular style.

duaraghav8 commented 6 years ago

Agreed, I believe the solidity style guide's rules are more suited as an optional ruleset (the current default ruleset is solium:all that you see in your .soliumrc.json which basically applies all the rules).

IMO here is how we can improve the linter:

I'll be working on it in the coming days. Feel free to give your input on this^, thanks for the detailed feedback!

duaraghav8 commented 6 years ago

v1.1.3 introduces the solium:recommended ruleset - https://github.com/duaraghav8/Solium/blob/master/config/rulesets/solium-recommended.js.

Would love to hear you out in case you have more feedback.