Quickly fix common code issues across a procedure, module, or project.
From the Inspection Results toolwindow, select an inspection result; the Fix dropdown menu lists all available quick-fixes for the selected result. Alternatively, simply right-click the result you want to apply a quick-fix to, and select the appropriate fix from the context menu.
Keep in mind that while static code analysis can easily and reliably spot syntactical elements (e.g. access modifiers, implicit keywords, etc.), analysis of code semantics is only as accurate as the internal representation of the code, and while 100% accuracy is the goal, in many cases it’s simply impossible: late-bound member calls (implicit or not) cannot be resolved, for example procedures invoked outside the VBA project (e.g. Excel user-defined functions, macros invoked by Access reports, etc.) are going to be reported as not used. Never blindly apply a quick-fix across an entire scope, module, or project, without first reviewing every individual result for a given inspection.
Exactly what a particular quick-fix does is entirely up to its implementation, but running any quick-fix will trigger an automatic reparse.
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.
Removes type hint characters from identifier declarations and value literals.
Removes the declaration for a variable that is never assigned. This operation may result in broken code if the unassigned variable is in use.
Removes an instruction that references a variable that isn't assigned. This operation may break the code.
Removes the declaration for a constant, variable, procedure, or line label that isn't used. This operation can break the code if the declaration is actually in use but Rubberduck couldn't find where.
Refactors a procedure's signature to remove a parameter that isn't used. Also updates usages.
Prompts for a new name, renames a declaration accordingly, and updates all usages.
Replaces empty string literals '""' with the 'vbNullString' constant.
Replaces 'Global' access modifier with the equivalent 'Public' keyword.
Simplifies conditional Boolean literal assignments with a direct assignment to the conditional expression.
Replaces the obsolete 'Error' statement with an 'ErrObject.Raise' member call.
Replaces 'While...Wend' loop statement with equivalent 'Do While...Loop'.
Introduces an error-handling subroutine to ensure error state is properly handled on scope exit.
Declares an explicit Variant return type for a procedure that implicitly returns a Variant.
Introduces an explicit 'ByRef' modifier for a parameter that is implicitly passed by reference.
Introduces an explicit 'Public' access modifier for a procedure that is implicitly public.
Splits multiple declarations into separate statements.
Replaces the use of a Variant-returning standard library function with its String-returning equivalent. Using this when the argument can be 'Null' will break the code.
Introduces a 'Set' keyword for what appears to be a suspicious or malformed object reference assignment.
Introduces a 'Property Get' member to make a write-only property read/write; Rubberduck will not infer the property's backing field, the body of the new member must be implemented manually.