Empty For Each...Next Block

Identifies empty 'For Each...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() Dim sheet As Worksheet For Each sheet In ThisWorkbook.Worksheets ' no executable statement... Next End Sub

This example should NOT trigger a result

MyModule (StandardModule)
Public Sub DoSomething() Dim sheet As Worksheet For Each sheet In ThisWorkbook.Worksheets Debug.Print sheet.Name Next End Sub

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