Inspection Details

FunctionReturnValueAlwaysDiscarded


Try it in the latest pre-release build!
Summary
Warns when a user function's return value is discarded at all 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.
Available quickfixes:
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()
    GetFoo ' return value is discarded
End Sub
Public Sub DoSomethingElse()
    Dim foo As Long
    foo = GetFoo ' return value is captured
End Sub
Private Function GetFoo() As Long
    GetFoo = 42
End Function


Back to List