Rubberduck
Rubberduck copied to clipboard
Inspection for redundant variable initializations
If a variable's first assignment (taking code paths into account) is a literal with the default value for that variable's declared type, Rubberduck should suggest removing that redundant assignment.
Dim foo As String
foo = vbNullString ' or ""
Dim foo As Integer ' or any numeric type actually
foo = 0
Dim foo As Boolean
foo = False
Dim foo As Object ' or any reference type
Set foo = Nothing
Dim foo As Date
foo = 0 ' 1899-12-30 12:00:00AM actually, so #1899-12-30#
Dim foo As Variant
foo = Empty ' vbEmpty still makes "(foo = vbEmpty)" evaluate to True, but converts to 0