Variable Not Used

Warns about variables that are never referenced.

Reasoning

A variable can be declared and even assigned, but if its value is never referenced, it's effectively an unused variable.

Default severity

Warning

Inspection type

CodeQualityIssues

Examples

This example should trigger a result

MyModule (StandardModule)
Public Sub DoSomething() Dim value As Long ' declared value = 42 ' assigned ' ... but never rerenced End Sub

This example should NOT trigger a result

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

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