Advanced Naming Rule Definitions

Aug 3, 2011 at 8:14 PM

Is there a way to enforce that variables names are at least 2 characters in length? Something like this - $(aaBB){2,}

Aug 3, 2011 at 9:58 PM
Edited Aug 3, 2011 at 9:59 PM


Recently I've added an ability to force some names to be at least 4 characters in length.
(some related info here and here)

Could you please try them out? Do they suit for your needs?

At the very beginning I was thinking about the syntax you suggested.
But it seemed to me a little bit complicated to configure (for example, if you wanted to prohibit short class names you would need to change rules for Class (internal), Class (not internal), etc...) and simply could not have this limit ">=2" written in one place. On the other hand, it could give much more flexibility.

So then I've decided to make this checking based on the same principle as "English only" and "Block @" checkings (just to make the implementation quicker).
As a result, checking length could be turned on for any of five "entity groups" without an ability of:
A. changing ">=4" condition
B. making different conditions for different entities

I also added a list of configurable exceptions for this rule.

What do you think about it? Maybe it would be enough to make ">=4" condition configurable (but leaving it global)?
Or it is strongly required to have different limits for variables and, e.g. classes?

Looking forward to your reply and real-usage feedback.
Thank you!

Best regards,
Oleg Shuruev

Aug 4, 2011 at 12:27 PM

Thanks for the info, Oleg. I am going to enable this rule and see how it goes with my team.