Variable Type Not Declared

Warns about variables declared without an explicit data type.

Reasoning

A variable declared without an explicit data type is implicitly a Variant/Empty until it is assigned.

Default severity

Warning

Inspection type

LanguageOpportunities

Examples

This example should trigger a result

MyModule (StandardModule)
Public Sub DoSomething() Dim value ' implicit Variant value = 42 ' ... End Sub

This example should NOT trigger a result

MyModule (StandardModule)
Public Sub DoSomething() Dim value As Long value = 42 ' ... End Sub

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