RDC01002 — Hungarian notation
Severity: Information · Family: RDC (Rubberduck Core analyzers) ·
Raised by: HungarianNotationAnalyzer
A name begins with a prefix that states its type.
strName and lngCount say in the name what the declaration says in its As clause, and go on saying it after the type changes. A name is reported when it begins with one of
a few common lowercase prefixes and what follows starts a new word, which an uppercase letter says: strName is, stringent and str are not. The prefixes are
arr, bln, byt, col, cur, dbl, dic, dtm, int, lng, lst, obj, rng, rs, sng, str, var, vnt, wb and ws.
The names it applies to are the ones the module chooses, like those of RDC01001. The diagnostic is an opinion of the analyzer and not a condition of the language.
The prefixes of the controls of a form (txt, cmd, lbl) are not among them, since the platform has no form controls yet.
Approving a name
A name that begins like one and that is not - colWidth is a width, and not a collection - is approved by listing it, in the Configuration:Diagnostics section of the extension's
appsettings.json. A name is compared without regard to case, and nothing is approved by default.
{
"Configuration": {
"Diagnostics": {
"HungarianNotation": {
"AllowedNames": [ "colWidth", "intervalStart" ]
}
}
}
}
The list is DiagnosticsOptions.HungarianNotation. 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 actions are a rename to the word after the prefix (strName to Name), when that word is a name nothing else means where the declaration is used, and a rename to a name the user chooses.
How it is raised
| Situation | Example | Resolution |
|---|---|---|
| A name chosen by the module begins with a prefix of its type, and is not approved. | Dim strName As String |
Name what it is, and let the declaration say the type: Dim customerName As String; or approve it. |
See also
- RD-VBAL §2.6.4 Rubberduck Core Diagnostics
- RDC01001 — a name that does not say what it names
ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca