Static code analysis can find hundreds of opportunities in VBA code.
Rubberduck builds its own internal representation of the code, and then proceeds to analyze it. Each individual inspection can easily be disabled, or configured to issue inspection results at different severity levels ranging from Hint
to Error
.
Use the Inspection Results toolwindow to review Rubberduck’s findings, search, filter, regroup results by inspection, location, type, or severity. Each inspection result comes with a detailed description of what’s being flagged and why, so you can make an enlightened decision.
Unless configured otherwise, Rubberduck automatically runs inspections after the a parser/resolver cycle completes (regardless of whether the inspection results toolwindow is displayed or not).
For the best experience, it would be recommended to first try Rubberduck with an empty project, add a new module, and write, say, a loop that counts 1 to 10 and outputs to the debug pane - then to parse that and review the inspection results; carefully review the inspection settings, and consider disabling the inspections that irreconcilably clash with your preferences: use meaningful names alone can easily produce hundreds upon hundreds of results if you’re not that much into using vowels, or if you, say, prefix all your variable names; these inspections can be re-enabled anytime you’re ready!
These features will be announced as \"new\" when they are merged into the [master] branch. Until then, they are only available in pre-release builds.
Warns about a variable that is assigned, and then re-assigned before the first assignment is read.
Default severity: Suggestion
The first assignment is likely redundant, since it is being overwritten by the second.
Locates unqualified Workbook.Worksheets/Sheets/Names member calls inside workbook document modules that implicitly refer to the containing workbook.
Default severity: Warning
Implicit references inside a workbook document module can be mistakes for implicit references to the active workbook, which is the behavior in all other modules By explicitly qualifying these member calls with Me, the ambiguity can be resolved.
This inspection will only run if the Excel library is referenced.
Locates unqualified Worksheet.Range/Cells/Columns/Rows member calls inside worksheet modules that implicitly refer to the containing sheet.
Default severity: Warning
Implicit references inside a worksheet document module can be mistakes for implicit references to the active worksheet, which is the behavior in all other places. By explicitly qualifying these member calls with Me, the ambiguity can be resolved.
This inspection will only run if the Excel library is referenced.
Flags the value-parameter of a property mutators that are declared with an explict ByRef modifier.
Default severity: Warning
Regardless of the presence or absence of an explicit ByRef or ByVal modifier, the value-parameter of a property mutator is always treated as though it had an explicit ByVal modifier. Exception: UserDefinedType and Array parameters are always passed by reference.