rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).

Home Page:https://rubberduckvba.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code Inspection - "Assignment is not used" incorrectly identified

JimG740 opened this issue · comments

Rubberduck version information
Version 2.5.9.6316
OS: Microsoft Windows NT 10.0.22621.0, x64
Host Product: Microsoft Office x64
Host Version: 16.0.17029.20108
Host Executable: EXCEL.EXE

Description
Code Inspection identifies the variable col = 0 as an assignment that is not used. Find All References, however, clearly shows that this variable is being used.
There are multiple similar instances of this type of error.

To Reproduce
Evident from Description and Screenshot

Expected behavior
Variable should not be flagged as "not used".

Screenshots
image

Logfile
RubberduckLog.txt

Additional context
Add any other context about the problem here.

The name of this inspection is ... not as clear as it needs to be. What Rubberduck is referencing is the fact that you basically have two assignments following each other without any read access to the variable in between.

It's basically saying that the first assignment is not contributing anything, since it's always overwritten with a different value before the variable is being read:

col = 0 ' assignment not used
col = ws.ListObjects(...) ' because this assignment overwrites it
' before it's being read the next time
If col = 0 Then

Just chipping in to mention that the website and its backend API haven't been looked at in several months, and with the current state of it I don't think it would pick up the new inspection name (or correctly mark the old version as deprecated), so not a showstopper in any way, but as far as unintended consequences go, ...the inspection's web link in the inspection results toolwindow is going to be a 404 if it's fixed & merged before the website gets a bit of attention... which might not realistically happen until I'm about to redesign the site to make some space for v3.