-
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 to require leading underscores in private variables #90
Comments
Hi @nventuro. I started to work on this rule and I could use some details. I'm curious about the reason for using a leading underscore in private and internal variables, but only in internal functions. Any reason not to use it in private variables too? I will make this configurable in the rule, but I would like to have some sensible default. Also, do you have any preference for the name of this rule? For now I'm going with cc @fernandomg |
More thoughts on this. I think having a single
On the other hand, having a single rule for each combination would be worse. We would have rules likes I think a reasonable middle ground is to have one naming rule for each entity:
Using the style guide for choosing the defaults. For example, in the previous config you could use just |
To clarify, we use it in all private variables, and private and internal functions. public variables, and public and external functions don't start with an underscore. An important exception I now realized I failed to mention is libraries: inside a
I don't mind this name at all! I'd rather it be descriptive than cryptic, forcing me to look up the documentation to understand what it means. Your proposal for the style of each construct is a good idea, in that it'd provide a lot of flexibility, but I'm not sure people actually need that level of granularity: I wouldn't worry too much about catering to all possible cases. |
Well, I ended up just doing a single rule for this. These are the test cases. @nventuro could you please tell me if they work for you?:
|
I ran this in your
By the way, |
Oh, you fixed that: e3aa88f 😅 |
Those test cases look good! There's only one you might want to change:
I think the default is Thanks for taking a look at the dev3.0 branch! From a quick overview those warnings seem to be correct - that's why we want a linter 😂 |
Hi! In OpenZeppelin we use leading underscores for
private
variables and functions, andinternal
functions (to both emphasize this attribute, and avoid clashing withpublic
names).Would it be possible to add a rule to enforce this sort of thing? I currently need to disable some rules, since e.g. I have
private
variables that are alsoconstant
(bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7
), and the snake case rule doesn't support leading underscores.Thanks!
The text was updated successfully, but these errors were encountered: