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
Wildcards in whitelist #4504
Comments
The whitelist doubles as a list of valid prefixes and identifiers: Use meaningful names would probably still fire results for numbered identifiers though... but it's specifically designed to do so. Numbered identifiers are a code smell; in a vast majority of cases, it is preferable to use an array or a collection of some sort - hence the by-design nature of flagging numbered identifiers as poor names. In VB6 you could have control arrays, unfortunately that isn't an option with MSForms in VBA. I don't completely disagree with supporting wildcards, but it seems to enable mass-undermining the use meaningful names inspection... something that can also be done by simply disabling it. If the number of players is unknown at compile-time, consider creating the textbox controls at run-time - in which case it becomes easy to use a name that doesn't trigger the inspection, and then you can craft a UI that is more representative of your domain model. OTOH if there's a fixed number of players and the UI can reasonably be made at design-time, I'd probably still want to whitelist each control name individually. So... I'm kinda torn on this one. |
If you're going to allow a wildcard, do you have to support |
Depends. If I'm writing a game of Battleship, yes (fixed players, few players: As for wildcards, I'd go with |
OTOH, this is an IDE, and we're matching identifiers. Pattern matching does make sense... But then I'd go RegEx over The crux of the problem seems to be that it's impossible to annotate a form control with an I'll keep this issue open and up-for-grabs, and won't refuse a PR that implements it... But I'm not sold at all on it being a good idea. |
An idea for implementation might be something like the following: Allow Wildcard specifications with
patterns that only contain wildcards could be rejected. Regex matches should be bounded on both ends with an anchor. |
I also wonder if this would be better if instead of wildcard, we only allow a range, which would close the range that could be match:
This way, those can be expanded into an array behind the scene. That wouldn't then require regex matching at all. |
@retailcoder - If the root issue is not being able to annotate One would be to allow whitelisting of Another would be to extend the |
Effectively whitelisting |
That was my thought. Hell, you could use it to ignore |
In my situation I do use a collection for the players themselves as objects, but the issue is with the controls on the user form displaying player info for which there is a specific maximum quantity that is known at design time(1 to a maximum of 6 active players and 0 to 4 deactivated players). It is no big deal to explicitly include each one in the whitelist.
Of course, since I don’t know about the inner workings and multiple uses RD has in the whitelist, my request was a bit out of school. I agree with a simple ? for a single character and # for a single digit with * for any number of characters or digits. No need to get any more complex than that I would think.
Thanks for the consideration and the education.
David
|
I’d like the idea of an annotation in lieu of going the whitelist route, but don’t know how that would be implemented for controls on a form (which is what got me onto this) unless it was hosted in the code behind (in the module declarations section?).
|
It would be nice to be able to use wildcards for names in the code inspection whitelist:
txtPlayerNumber1, txtPlayerNumber2, txtPlayerNumber3, etc, could be specified in a single entry as txtPlayerNumber#
The text was updated successfully, but these errors were encountered: