Inspection Details

FunctionReturnValueNotUsed


Summary
Warns when a user function's return value is never used, at any of its call sites.
Reasoning
A 'Function' procedure normally means its return value to be captured and consumed by the calling code. It's possible that not all call sites need the return value, but if the value is systematically discarded then this means the function is side-effecting, and thus should probably be a 'Sub' procedure instead.
The following code example(s) would trigger this inspection:

Public Sub DoSomething()
    GetFoo ' return value is not captured
End Sub
Private Function GetFoo() As Long
    GetFoo = 42
End Function

The following code example(s) would not trigger this inspection:

Public Sub DoSomething()
    Dim foo As Long
    foo = GetFoo
End Sub
Private Function GetFoo() As Long
    GetFoo = 42
End Function


Back to List