-
Notifications
You must be signed in to change notification settings - Fork 301
Code Inspections
Rubberduck provide code analysis via the Code Inspections functionality. The code in all open VBA Projects is parsed and Rubberduck suggests improvements. Many of these can be automatically corrected by the add in by using the "Fix" button.
Quickfixes are not intended to be used blindly, and some of them may end up leaving the code non-compilable (like removing the declaration for a variable that's referenced, but never assigned to). Inspection results should not be considered as an obligation to change anything about the code; they are meant to inform the maintainer about these issues.
- ImplicitByRefParameterInspection
- ImplicitPublicMemberInspection
- ImplicitVariantReturnTypeInspection
- ModuleOptionsNotSpecifiedFirstInspection
- MultipleDeclarationsInspection
- NonReturningFunctionInspection
- ObsoleteCallStatementInspection
- ObsoleteCommentSyntaxInspection
- ObsoleteGlobalInspection
- ObsoleteLetStatementInspection
- ObsoleteTypeHintInspection
- OptionBaseInspection
- OptionExplicitInspection
- ParameterCanBeByValInspection
- ParameterNotUsedInspection
- UnassignedVariableUsageInspection
- VariableNotDeclaredInspection
- VariableTypeNotDeclaredInspection
Code Inspections are configurable and stored in the Rubberduck.config
file that is installed along with the add-in to the C:\Users\Username\AppData\Roaming\Rubberduck\
directory.
Severity levels can be set through the Settings dialog by going to Rubberduck >> Settings:
The Code Inspection Settings section lists severity levels for each individual inspection:
Severity levels can be configured to any of the following:
- Do Not Show turns off an inspection.
- Hint level would be for inspections that raise a flag, something to keep in mind while maintaining the code.
- Suggestion level is for inspections that can enhance the code base.
- Warning level is for potentially serious issues.
- Error level is for definitely serious issues that can result in compilation or runtime errors, or unexpected bugs.
By default, the Ctrl+Shift+I hotkey brings up the Inspection Results toolwindow:
The Refresh command requests a re-parse of everything in the IDE, which updates inspection results and everything else that needs the parse trees.
The Fix button is actually a dynamic drop-down menu that lists all quick-fixes supported by the selected inspection result. Most inspections support an ignore once quick-fix that inserts a special annotation instructing Rubberduck to ignore a specific place in the code for a specific inspection.
The Grouping button is also a drop-down, that lets you regroup inspection results either by location (module) or by inspection type.
The Copy button copies inspection results to various formats in the clipboard, so you can paste them as a formatted table in Excel, as HTML in Word, or as plain text in a Code Review Stack Exchange post.
The Settings button brings up the settings dialog on the inspection settings page, to let you configure inspection severities.
The bottom pane (which can be dragged/resized vertically) contains information about the selected inspection result, as well as quick links to apply the default fix (the one that's listed first in the Fix drop-down) to the entire module or project, and a link to automatically disable an inspection (i.e. automatically set its severity level to DoNotShow
).
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