Description
What
Functions and property getters in VBA/VB6 don't need to explicitly return anything in every execution path, or at all actually. Let's implement an inspection that flags functions and property getters that wouldn't compile in VB.NET because not all code paths return a value.
Why
This inspection would be useful for code that needs to easily portable to .NET, and could potentially prevent bugs. It's different than "Function return value is not assigned", which doesn't care for code paths and is happy with one execution path leading to the function actually returning something: arguably this should probably be an enhancement/tweak to the existing inspection.
Example
This code should trigger the inspection:
Public Function GetFoo(ByVal bar As Boolean) As Long
If bar Then GetFoo = 42 'condition may not always be True, returning an unintended (?) 0.
End Sub
This code should NOT trigger the inspection:
Public Function GetFoo() As Long
If True Then GetFoo = 42 'condition is provably constant, all code paths return 42.
End Sub
QuickFixes
I don't think a simple (?) quickfix is implementable for this.
Resources
TBC