Unhandled on Error Resume Next

Finds instances of 'On Error Resume Next' that don't have a corresponding 'On Error GoTo 0' to restore error handling.

Reasoning

'On Error Resume Next' should be constrained to a limited number of instructions, otherwise it supresses error handling for the rest of the procedure; 'On Error GoTo 0' reinstates error handling. This inspection helps treating 'Resume Next' and 'GoTo 0' as a code block (similar to 'With...End With'), essentially.

Default severity

Warning

Inspection type

CodeQualityIssues

Examples

This example should trigger a result

MyModule (StandardModule)
Public Sub DoSomething() On Error Resume Next ' error handling is never restored in this scope. ' ... End Sub

This example should NOT trigger a result

MyModule (StandardModule)
Public Sub DoSomething() On Error Resume Next ' ... On Error GoTo 0 End Sub

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