Empty Else Block

Identifies empty 'Else' blocks that can be safely removed.

Reasoning

Empty code blocks are redundant, dead code that should be removed. They can also be misleading about their intent: an empty block may be signalling an unfinished thought or an oversight.

Default severity

Warning

Inspection type

NamingAndConventionsIssues

Examples

This example should trigger a result

MyModule (StandardModule)
Public Sub DoSomething(ByVal foo As Boolean) If foo Then ' ... Else End If End Sub

This example should NOT trigger a result

MyModule (StandardModule)
Public Sub DoSomething(ByVal foo As Boolean) If foo Then ' ... End If End Sub

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