RDC01001 — Use meaningful identifier names
Severity: Information · Family: RDC (Rubberduck Core analyzers) ·
Raised by: UseMeaningfulIdentifierNamesAnalyzer
A name does not say what it names.
A name is reported when it breaks one of the rules of Rubberduck's meaningful names inspection, the first it breaks being the one that is told:
| Rule | Example |
|---|---|
| It has fewer than 3 characters. | x, ws |
| It ends with a digit: it says it is one of several, and not what makes it different from the others. | total1, Sheet2 |
It has no vowel, and is unlikely to be a word. A vowel is an a, e, i, o or u, accented or not. |
tmp, cnt |
The names it applies to are the ones the module chooses: variables, constants, parameters, procedures, properties, events, enumerations and their members, user-defined types and their
fields. A procedure of an external library is named by the library, and a procedure that has an underscore in its name implements an interface member, handles an event or is a lifecycle
handler (Class_Initialize): they are named by the interface, the event and the language, and are not reported. The accessors of a property are one name. The diagnostic is an opinion of
the analyzer and not a condition of the language.
Approving a name
A name that breaks a rule and that is fine - the counter of a loop is i - is approved by listing it, in the Configuration:Diagnostics section of the extension's
appsettings.json. A name is compared without regard to case, like every identifier of the language, and nothing is approved by default.
{
"Configuration": {
"Diagnostics": {
"MeaningfulNames": {
"AllowedNames": [ "i", "j", "k", "x", "y" ]
}
}
}
}
The list is DiagnosticsOptions.MeaningfulNames. It is a suggestion because renaming does not change what the declaration is.
Fixing it
The diagnostic is fixed by renaming the declaration, which renames every name that refers to it (textDocument/rename). Its code action is a rename to a name the user chooses: only the user can say what the name means.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
| A name chosen by the module breaks a rule and is not approved. | Dim tmp As Long |
Give it a name that says what it is: Dim remainder As Long; or approve it. |
See also
- RD-VBAL §2.6.4 Rubberduck Core Diagnostics
- RDC01002 — a name with a prefix that states its type
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca