rubberduck-vba / Rubberduck

Every programmer needs a rubberduck. COM add-in for the VBA & VB6 IDE (VBE).
https://rubberduckvba.com
GNU General Public License v3.0
1.92k stars 302 forks source link

Unused variables in Code Quality window #6148

Closed paweston70 closed 1 year ago

paweston70 commented 1 year ago

Rubberduck version information The info below can be copy-paste-completed from the first lines of Rubberduck's log or the About box:

Version 2.5.9.6291
OS: Microsoft Windows NT 10.0.19045.0, x64
Host Product: Microsoft Office x64
Host Version: 16.0.16626.20170
Host Executable: MSACCESS.EXE

Description When Rubberduck checks the code quality it reports some variables as not being used, when they clearly are.

To Reproduce Obvious.

Expected behavior The code should be examined in the whole of the current block before declaring a quality issue.

Screenshots image

Logfile RubberduckLog.txt

BZngr commented 1 year ago

If a variable is written but never read, it is flagged by the inspection. See also #6134

If cbd is ever read later within the method provided as an example, then it would be a bug.

paweston70 commented 1 year ago

Apologies - you are absolutely right; I missed the variable later on in the code.