Variable Not Assigned

Warns about variables that are never assigned.

Reasoning

A variable that is never assigned is probably a sign of a bug. This inspection may yield false positives if the variable is assigned through a ByRef parameter assignment, or if UserForm controls fail to resolve, references to these controls in code-behind can be flagged as unassigned and undeclared variables.

Default severity

Warning

Inspection type

CodeQualityIssues

Examples

This example should trigger a result

MyModule (StandardModule)
Public Sub DoSomething() Dim value As Long ' declared, but not assigned ' ... 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.VariableNotAssignedInspection.cs (Prerelease-v2.5.9.6289)