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!
This tab lists all items found in the .xml documentation assets from the latest pre-release build. To modify this content, a pull request must be merged into the [next] branch.
Flags parameters declared across multiple physical lines of code.
Default severity: Suggestion
When splitting a long list of parameters across multiple lines, care should be taken to avoid splitting a parameter declaration in two.
Flags declaration statements spanning multiple physical lines of code.
Default severity: Warning
Declaration statements should generally declare a single variable.
Warns about 'Function' and 'Property Get' procedures whose return value is not assigned.
Default severity: Error
Both 'Function' and 'Property Get' accessors should always return something. Omitting the return assignment is likely a bug.
Warns about assignments that appear to be assigning an object reference without the 'Set' keyword.
Default severity: Error
Omitting the 'Set' keyword will Let-coerce the right-hand side (RHS) of the assignment expression. If the RHS is an object variable, then the assignment is implicitly assigning to that object's default member, which may raise run-time error 91 at run-time.
Identifies places in which an object is used but a procedure is required and a default member exists on the object.
Default severity: Warning
Providing an object where a procedure is required leads to an implicit call to the object's default member. This behavior is not obvious, and most likely unintended.
Warns about 'Declare' statements that are using the obsolete/unsupported 'CDecl' calling convention on Windows.
Default severity: Warning
The CDecl calling convention is only implemented in VBA for Mac; if Rubberduck can see it (Rubberduck only runs on Windows), then the declaration is using an unsupported (no-op) calling convention on Windows.
Locates explicit 'Call' statements.
Default severity: Suggestion
The 'Call' keyword is obsolete and redundant, since call statements are legal and generally more consistent without it.
Locates legacy 'Rem' comments.
Default severity: Suggestion
Modern VB comments use a single quote character (') to denote the beginning of a comment: the legacy 'Rem' syntax is obsolete.
Locates legacy 'Error' statements.
Default severity: Suggestion
The legacy syntax is obsolete; prefer 'Err.Raise' instead.
Locates legacy 'Global' declaration statements.
Default severity: Suggestion
The legacy syntax is obsolete; use the 'Public' keyword instead.