Function Return Value Discarded

Warns when a user function's return value is not used at a call site.

Reasoning

A 'Function' procedure normally means its return value to be captured and consumed by the calling code.

Default severity

Warning

Inspection type

CodeQualityIssues

Examples

This example should trigger a result

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

This example should NOT trigger a result

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

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