Suspicious Let Assignment

Identifies assignments without Set for which both sides are objects.

Reasoning

Whenever both sides of an assignment without Set are objects, there is an assignment from the default member of the RHS to the one on the LHS. Although this might be intentional, in many situations it will just mask an erroneously forgotten Set.

Default severity

Warning

Inspection type

CodeQualityIssues

Examples

This example should trigger a result

MyModule (StandardModule)
Public Sub DoSomething(ByVal rng As Excel.Range, ByVal arg As ADODB Field) rng = arg End Sub

This example should NOT trigger a result

MyModule (StandardModule)
Public Sub DoSomething(ByVal rng As Excel.Range, ByVal arg As ADODB Field) rng.Value = arg.Value End Sub

This example should NOT trigger a result

MyModule (StandardModule)
Public Sub DoSomething(ByVal rng As Excel.Range, ByVal arg As ADODB Field) Let rng = arg End Sub

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