Closed JimG740 closed 10 months ago
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
I am impressed with the rapid response. Thank you for the clarification.
It would seem to me that a very simple software change would be to modify the inspection description to "unnecessary variable assignment". A simple change with virtually no threat of "unintended software consequences" .
From: Clemens Lieb @.> Sent: Tuesday, January 2, 2024 1:02 PM To: rubberduck-vba/Rubberduck @.> Cc: JimG740 @.>; Author @.> Subject: Re: [rubberduck-vba/Rubberduck] Code Inspection - "Assignment is not used" incorrectly identified (Issue #6190)
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
— Reply to this email directly, view it on GitHubhttps://github.com/rubberduck-vba/Rubberduck/issues/6190#issuecomment-1874362487, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BFCENREPSPIAMANB2QWC5TLYMRDTZAVCNFSM6AAAAABBKKPEKCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZUGM3DENBYG4. You are receiving this because you authored the thread.Message ID: @.***>
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.
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
Logfile RubberduckLog.txt
Additional context Add any other context about the problem here.