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.
Identifies the use of indexed default member accesses for which the default member cannot be determined at compile time.
Default severity: Warning
Default member accesses hide away the actually called member. This is especially misleading if there is no indication in the expression that such a call is made and if the default member cannot be determined from the declared type of the object. As a consequence, errors in which a member was forgotten to be called can go unnoticed and should there not be a suitable default member at runtime, an error 438 'Object doesn't support this property or method' will be raised.
Warns about 'Function' and 'Property Get' procedures that don't have an explicit return type.
Default severity: Hint
All functions return something, whether a type is specified or not. The implicit default is 'Variant'.
Identifies the use of indexed default member accesses.
Default severity: Warning
An indexed default member access hides away the actually called member.
Identifies the use of indexed default member accesses that require a recursive default member resolution.
Default severity: Warning
An indexed default member access hides away the actually called member. This is especially problematic if the corresponding parameterized default member is not on the interface of the object itself.
Identifies the use of indexed default member accesses for which the default member cannot be determined at compile time.
Default severity: Warning
An indexed default member access hides away the actually called member. This is especially problematic if the default member cannot be determined from the declared type of the object. Should there not be a suitable default member at runtime, an error 438 'Object doesn't support this property or method' will be raised.
Identifies obsolete 16-bit integer variables.
Default severity: Hint
Modern processors are optimized for processing 32-bit integers; internally, a 16-bit integer is still stored as a 32-bit value. Unless code is interacting with APIs that require a 16-bit integer, a Long (32-bit integer) should be used instead.
Identifies uses of 'IsMissing' involving non-variant, non-optional, or array parameters.
Default severity: Warning
'IsMissing' only returns True when an optional Variant parameter was not supplied as an argument. This inspection flags uses that attempt to use 'IsMissing' for other purposes, resulting in conditions that are always False.
Identifies uses of 'IsMissing' involving a non-parameter argument.
Default severity: Warning
'IsMissing' only returns True when an optional Variant parameter was not supplied as an argument. This inspection flags uses that attempt to use 'IsMissing' for other purposes, resulting in conditions that are always False.
Identifies line labels that are never referenced, and therefore superfluous.
Default severity: Warning
Line labels are useful for GoTo, GoSub, Resume, and On Error statements; but the intent of a line label can be confusing if it isn't referenced by any such instruction.
Warns about member calls against an extensible interface, that cannot be validated at compile-time.
Default severity: Warning
Extensible COM types can have members attached at run-time; VBA cannot bind these member calls at compile-time. If there is an early-bound alternative way to achieve the same result, it should be preferred.
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.
Warns about a malformed Rubberduck annotation that is missing one or more arguments.
Default severity: Error
Some annotations require arguments; if the required number of arguments isn't specified, the annotation is nothing more than an obscure comment.
Indicates that a Rubberduck annotation is documenting the presence of a VB attribute that is actually missing.
Default severity: Warning
Rubberduck annotations mean to document the presence of hidden VB attributes; this inspection flags annotations that do not have a corresponding VB attribute.
Indicates that a hidden VB attribute is present for a member, but no Rubberduck annotation is documenting it.
Default severity: Warning
Rubberduck annotations mean to document the presence of hidden VB attributes; this inspection flags members that do not have a Rubberduck annotation corresponding to the hidden VB attribute.
Indicates that a hidden VB attribute is present for a module, but no Rubberduck annotation is documenting it.
Default severity: Warning
Rubberduck annotations mean to document the presence of hidden VB attributes; this inspection flags modules that do not have a Rubberduck annotation corresponding to the hidden VB attribute.
Warns about module-level declarations made using the 'Dim' keyword.
Default severity: Suggestion
Private module variables should be declared using the 'Private' keyword. While 'Dim' is also legal, it should preferably be restricted to declarations of procedure-scoped local variables, for consistency, since public module variables are declared with the 'Public' keyword.
Indicates that a user module is missing a @Folder Rubberduck annotation.
Default severity: Suggestion
Modules without a custom @Folder annotation will be grouped under the default folder in the Code Explorer toolwindow. By specifying a custom @Folder annotation, modules can be organized by functionality rather than simply listed.
Locates module-level fields that can be moved to a smaller scope.
Default severity: Hint
Module-level variables that are only used in a single procedure can often be declared in that procedure's scope. Declaring variables closer to where they are used generally makes the code easier to follow.
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.