Line Label Not Used

Identifies line labels that are never referenced, and therefore superfluous.

Reasoning

Line labels are useful for GoTo, GoSub, Resume, and On Error statements; but the intent of a line label can be confusing if it isn't referenced by any such instruction.

Default severity

Warning

Inspection type

CodeQualityIssues

Examples

This example should trigger a result

MyModule (StandardModule)
Public Sub DoSomething() ' On Error GoTo ErrHandler ' (commented-out On Error statement leaves line label unreferenced) ' ... Exit Sub ErrHandler: ' ... End Sub

This example should NOT trigger a result

MyModule (StandardModule)
Public Sub DoSomething() On Error GoTo ErrHandler ' ... Exit Sub ErrHandler: ' ... End Sub

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