Empty For...Next Block

Identifies empty 'For...Next' blocks that can be safely removed.

Reasoning

Dead code should be removed. A loop without a body is usually redundant.

Default severity

Warning

Inspection type

NamingAndConventionsIssues

Examples

This example should trigger a result

MyModule (StandardModule)
Public Sub DoSomething(ByVal foo As Long) Dim i As Long For i = 0 To foo ' no executable statement... Next End Sub

This example should NOT trigger a result

MyModule (StandardModule)
Public Sub DoSomething(ByVal foo As Long) Dim i As Long For i = 0 To foo Debug.Print i Next End Sub

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