Skip to content

VariableNotAssignedInspection

Mathieu Guindon edited this page Feb 23, 2015 · 2 revisions

Description: Variable is never assigned

Type: CodeInspectionType.CodeQualityIssues

Default severity: CodeInspectionSeverity.Hint

This inspection finds global-scope, module-scope and procedure-scope variables that are never assigned to.

###Example:

Variable foo is never assigned in this procedure:

Public Sub DoSomething()
    Dim foo As Integer
    DoSomethingElse 42
End Sub

Declarations of unassigned variables can be safely removed. Usages of unassigned variables are likely bugs.


###QuickFixes

QuickFix: Remove unassigned variable

Public Sub DoSomething()
    DoSomethingElse 42
End Sub

This quickfix simply removes the unused declaration; if Option Explicit is specified, doing this will break any/all usages of the unassigned variable. If Option Explicit is not specified, removing the declaration has no effect.

Clone this wiki locally