Module Scope Dim Keyword

Warns about module-level declarations made using the 'Dim' keyword.

Reasoning

Private module variables should be declared using the 'Private' keyword. While 'Dim' is also legal, it should preferably be restricted to declarations of procedure-scoped local variables, for consistency, since public module variables are declared with the 'Public' keyword.

Default severity

Suggestion

Inspection type

LanguageOpportunities

Examples

This example should trigger a result

MyModule (StandardModule)
Option Explicit Dim foo As Long ' ...

This example should NOT trigger a result

MyModule (StandardModule)
Option Explicit Private foo As Long ' ...

Rubberduck.CodeAnalysis.Inspections.Concrete.ModuleScopeDimKeywordInspection.cs (Prerelease-v2.5.9.6289)