-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Add checkstyle precommit for hidden/shadowed variables #19752
Comments
I assume that we would configure it so that this does not apply to constructor parameters nor to setter parameters? |
Yep, those are options we can definitely enable |
Pinging @elastic/es-core-infra |
@dakrone, do you still think this is worth it? |
Do we still want to do this? I enabled the We could enable it as a warning, or an IDE-only warning? |
@pugnascotia I mean, I still want it, but I'm pretty opinionated about shadowing variables. Given that this is almost five years old, other people may have different opinions :D |
I guess there's two things:
|
For me shadowing is all about code readability. It's right up there with having a 140 character limit, sure we may not break things (well, in shadowing's case, we might), but it's so much easier to read code that doesn't shadow variables. |
Part of #19752. Fix a number of locations where local variables or parameters are shadowing a field that is defined in the same class.
Part of #19752. Fix a number of locations where local variables or parameters are shadowing a field that is defined in the same class.
Part of #19752. Fix a number of cases of shadows vars under `client/rest-high-level`. As part of this, fork the Checkstyle `HiddeFieldCheck` class so that it understand the pattern of settings with no "set" prefix.
Part of #19752. Fix a number of cases of shadows vars under `client/rest-high-level`. As part of this, fork the Checkstyle `HiddeFieldCheck` class so that it understand the pattern of settings with no "set" prefix.
Part of #19752. Fix more instances where local variable names were shadowing field names.
Part of elastic#19752. Fix more instances where local variable names were shadowing field names. Also modify our fork of HiddenFieldCheck to add the ignoreConstructorBody and ignoredMethodNames parameters, so that the check can ignore more matches.
Part of #19752. Fix more instances where local variable names were shadowing field names. Also: * Remove unused bits and pieces from `XPackClientPlugin`. * Expand the possible method names that are skipped when checking for shadowed vars, and allow shadowed vars in builder classes.
Part of #19752. Fix more instances where local variable names were shadowing field names. Also: * Remove unused bits and pieces from `XPackClientPlugin`. * Expand the possible method names that are skipped when checking for shadowed vars, and allow shadowed vars in builder classes.
Part of elastic#19752. Fix more instances where local variable names were shadowing field names. Also expand the possible method names that are skipped when checking for shadowed vars, and allow shadowed vars in builder classes.
Part of #19752. Fix more instances where local variable names were shadowing field names. Also modify our fork of HiddenFieldCheck to add the ignoreConstructorBody and ignoredMethodNames parameters, so that the check can ignore more matches. Co-authored-by: Elastic Machine <[email protected]>
Part of #19752. Fix more instances where local variable names were shadowing field names.
Part of #19752. Fix more instances where local variable names were shadowing field names.
Part of elastic#19752. Fix more instances where local variable names were shadowing field names.
Part of #19752. Fix more instances where local variable names were shadowing field names.
Part of #19752. Fix more instances where local variable names were shadowing field names.
Backport of elastic#81361. Part of elastic#19752. Fix more instances where local variable names were shadowing field names.
Part of #19752. Fix more instances where local variable names were shadowing field names.
Part of #19752. Fix more instances where local variable names were shadowing field names.
@pugnascotia correct me if I'm wrong but I think we're all done here? |
Nope, I just ran out of steam with fixing up instances of shadowed vars. I can pick it up again though. |
Pinging @elastic/es-delivery (Team:Delivery) |
Checkstyle has the ability to detect when variables are shadowed by local variables: http://checkstyle.sourceforge.net/config_coding.html#HiddenField
We should enable this as it makes reading the code clearer, as well as reducing potential bugs with missing
this.
prefixes.The text was updated successfully, but these errors were encountered: