-
Notifications
You must be signed in to change notification settings - Fork 301
UnassignedVariableUsageInspection
Description: Use of unassigned variable
Type: CodeInspectionType.CodeQualityIssues
Default severity: CodeInspectionSeverity.Error
This inspection finds all usages of unassigned variables.
Field foo
is referenced, but it's never assigned.
Dim foo As Integer
Public Sub DoSomething()
Dim bar
bar = foo
End Sub
When a variable is used, but never assigned, it's unlikely that the code is doing what it should be doing. Note that this inspection will not catch whether a variable is actually assigned before it is used.
QuickFix: Remove usage (breaks code)
Dim foo As Integer
Public Sub DoSomething()
Dim bar
bar = TODO
End Sub
This quickfix replaces the unassigned reference with a TODO
placeholder that is meant to break the code - if there's actually a declared variable in-scope that's called TODO
, then this may be a problem. Otherwise, the idea is to put the code in a state that clearly needs to be addressed, as opposed to a state that merely compiles, but doesn't work as intended.
rubberduckvba.com
© 2014-2021 Rubberduck project contributors
- Contributing
- Build process
- Version bump
- Architecture Overview
- IoC Container
- Parser State
- The Parsing Process
- How to view parse tree
- UI Design Guidelines
- Strategies for managing COM object lifetime and release
- COM Registration
- Internal Codebase Analysis
- Projects & Workflow
- Adding other Host Applications
- Inspections XML-Doc
-
VBE Events