Inspections

Most code inspections propose at least one quick fix that can be applied with a single click. Severity levels range from Do Not Show to Error and are completely configurable, for every single inspection.

Always review inspection results before applying a quick fix.


Code Inspections

Name / Message Description
ApplicationWorksheetFunction

Late bound WorksheetFunction call.

The Excel Application object does not implement the WorksheetFunction interface directly. All calls made to WorksheetFunction members are handled as late bound and errors in the called member will be returned wrapped in a Variant of VbVarType.vbError. This makes errors un-trappable with error handlers and adds a performance penalty in comparison to early bound calls. Consider calling Application.WorksheetFunction explicitly. Note: If this call generated errors in the past, those errors were ignored. If applying the quick fix, proper error handling should be in place.
AssignedByValParameter

ByVal parameter is assigned

Parameter is passed by value, but is assigned a new value/reference. Consider making a local copy instead if the caller isn't supposed to know the new value. If the caller should see the new value, the parameter should be passed ByRef instead, and you have a bug.
BooleanAssignedInIfElse

Boolean literal assignment in conditional

A member is assigned True/False in different branches of an if statement with no other statements in the conditional. Use the condition directly to the member instead.
ConstantNotUsed

Constant is not used

Rubberduck could not find any reference to constant. Consider removing the unused declaration.
DefaultProjectName

Project name is not specified

Consider naming your VBA project.
DefTypeStatement

Usage of 'Def[Type]' statement

Using the 'Def[Type]' statement leads to specifying types by using a prefix. This style of naming is heavily discouraged and should be avoided.
EmptyCaseBlock

Empty 'Case' block

An empty 'Case' block without any executable statements, leaves a maintainer wondering about the intent of the code. Avoid writing code that doesn't need to be written.
EmptyDoWhileBlock

Empty 'Do...While' Loop

An empty 'Do...While' loop without any executable statements, leaves a maintainer wondering about the intent of the code. Avoid writing code that doesn't need to be written.
EmptyElseBlock

Empty 'Else' block

An empty 'Else' loop without any executable statements, leaves a maintainer wondering about the intent of the code. Avoid writing code that doesn't need to be written.
EmptyForEachBlock

Empty 'For Each...Next' Loop

An empty 'For Each...Next' loop without any executable statements, leaves a maintainer wondering about the intent of the code. Avoid writing code that doesn't need to be written.
EmptyForLoopBlock

Empty 'For...Next' Loop

An empty 'For...Next' loop without any executable statements, leaves a maintainer wondering about the intent of the code. Avoid writing code that doesn't need to be written.
EmptyIfBlock

Empty conditional branch

An empty conditional branch without any executable statements, leaves a maintainer wondering about the intent of the code. Avoid writing code that doesn't need to be written.
EmptyModule

Empty module

Empty modules and classes either point to not yet implemented functionality or represent unnecessary baggage that can hurt the maintainability of a project.
EmptyStringLiteral

Empty string literal

The built-in constant 'vbNullString' is a null string pointer taking up 0 bytes of memory, that unambiguously conveys the intent of an empty string.
EmptyWhileWendBlock

Empty 'While...Wend' loop

An empty 'Loop' block without any executable statements, leaves a maintainer wondering about the intent of the code. Avoid writing code that doesn't need to be written.
EncapsulatePublicField

Public field breaks encapsulation

Consider exposing a property instead.
FunctionReturnValueNotUsed

Function return value is never used

A member is written as a function, but used as a procedure. Unless the function is recursive, consider converting the 'Function' into a 'Sub'. If the function is recursive, none of its external callers are using the returned value.
HostSpecificExpression

Host-specific bracketed expression is only evaluated at runtime

Bracketed expressions are evaluated by the host application at runtime, which means VBA can't validate the expression at compile-time. Consider using the host application's object model instead.
HungarianNotation

Variable uses Hungarian notation.

Hungarian notation makes code less readable, and is redundant when strongly typed variables and meaningful names are used.
IllegalAnnotation

Illegal annotation

An annotation meant to be specified at module level cannot be used to annotate members; annotations meant to be annotate members cannot be used at module level; module and member annotations should only be specified once.
ImplicitActiveSheetReference

Implicit reference to ActiveSheet

Implicit references to the active sheet make the code frail and harder to debug. Consider making these references explicit when they're intended, and prefer working off object references. Ignore if the member call is referring to a type Rubberduck can't resolve.
ImplicitActiveWorkbookReference

Implicit reference to ActiveWorkbook

Implicit references to the active workbook make the code frail and harder to debug. Consider making these references explicit when they're intended, and prefer working off object references. Ignore if the member call is referring to a type Rubberduck can't resolve.
ImplicitByRefModifier

Implicit ByRef parameter

Parameters are passed by reference unless specified otherwise, which can be confusing and bug-prone. Prefer passing parameters by value, and specify ByRef explicitly when passing parameters by reference.
ImplicitDefaultMemberAssignment

Implicit default member assignment

Such assignments look like they are assigning an object variable to a value type on the surface, but they are actually assigning that object's default member, implicitly. Consider referring to the default member explicitly, for improved readability.
ImplicitPublicMember

Implicitly public member

Module members are public by default, which can be counter-intuitive. Consider specifying explicit access modifiers to avoid ambiguity.
ImplicitVariantReturnType

Member return type is implicitly 'Variant'

Members with a return value implicitly return a 'Variant' unless specified otherwise. Consider returning an explicit 'Variant' when the return type isn't known, or specify it explicitly.
IntegerDataType

Use of 16-bit integer type

The maximum value of a 16-bit signed integer is 32,767 - using a 32-bit (Long) integer data type where possible can help prevent 'Overflow' run-time errors, and is better handled by modern CPUs.
LineLabelNotUsed

Line label is not used

A line label that is never jumpted to ('GoTo', 'Resume', ...), serves no purpose. Consider removing it.
MemberNotOnInterface

Member not found

A member access call is made against an extended interface that Rubberduck couldn't resolve, or the member couldn't be found. If VBA cannot resolve the type at run-time, error 438 will be raised. If an equivalent, non-extended interface that Rubberduck can resolve is available, consider using it instead.
MissingAnnotationArgument

Missing annotation parameter

An annotation parameter is missing or incorrectly specified. The correct syntax is : '@Annotation([parameter])\nExample: '@Folder("Parent.Child")
MissingAttribute

Missing attribute

A Rubberduck annotation is specified for a module or member, but the corresponding attribute isn't present. Module attributes and annotations need to be synchronized.
ModuleScopeDimKeyword

Use of 'Dim' keyword at module level

The 'Public' keyword can only be used at module level; its counterpart 'Private' can also only be used at module level. 'Dim' however, can be used to declare both procedure and module scope variables. For consistency, it would be preferable to reserve 'Dim' for locals, and thus to use 'Private' instead of 'Dim' at module level.
MoveFieldCloserToUsage

Scope of variable is broader than it needs to be

A module-level variable used only in one procedure should be declared in that procedure.
MultilineParameter

Parameter declaration is split on multiple lines

Consider continuing long signatures between parameters. Splitting a parameter declaration across multiple lines arguably hurts readability.
MultipleDeclarations

Multiple declarations in single instruction

Declaring multiple variables in the same instruction is legal, but should be used sparingly. Consider declaring variables closer to their usage, in a single instruction per declaration.
NonReturningFunction

Non-returning function or property getter

This is likely a bug. The return value of a function or property getter must be assigned before exiting, otherwise the program will not be working with expected results. If a function has no meaningful return value, consider declaring it as a 'Sub' procedure instead.
ObjectVariableNotSet

Object variable assignment requires 'Set' keyword

As far as Rubberduck can tell, this variable is an object variable, assigned without the 'Set' keyword. This causes run-time error 91 'Object or With block variable not set'.
ObsoleteCallStatement

Use of obsolete 'Call' statement

The 'Call' statement is no longer required to call procedures, and only exists in the language to support legacy code that required it; it can be safely rewritten to an implicit call.
ObsoleteCommentSyntax

Use of obsolete 'Rem' statement

The 'Rem' statement only exists in the language to support legacy code that required it; it can be safely replaced with an apostrophe / single-quote comment.
ObsoleteErrorSyntax

Use of obsolete 'Error' statement

The 'Error' statement only exists in the language to support legacy code that required it; prefer using 'Err.Raise' instead.
ObsoleteGlobal

Use of obsolete 'Global' access modifier

The 'Global' keyword only exists in the language to support legacy code that required it; it can be safely replaced with the 'Public' modifier.
ObsoleteLetStatement

Use of obsolete explicit 'Let' statement

The 'Let' statement only exists in the language to support legacy code that required it; it can be safely removed, since modern VBA does not require that keyword for value assignments.
ObsoleteTypeHint

Obsolete Type hint usage

Type hint characters only exist in the language to support legacy code that required it; they can be safely replaced in declarations with an "As" type clause that specifies the type explicitly, and they can be omitted in other identifier references.
OptionBase

'Option Base 1' is specified

Arrays are typically zero-based. This option changes the default lower boundary for implicitly-sized arrays, which can introduce off-by-one errors if one isn't cautious.
OptionExplicit

'Option Explicit' is not specified

VBA will happily compile a typo: use 'Option Explicit' to prevent successfully compiling an erroneous program.
ParameterCanBeByVal

Parameter can be passed by value

A parameter that is passed by reference and isn't assigned a new value/reference, could be passed by value instead.
ParameterNotUsed

Parameter is not referred to

A parameter is passed into a member that does not use it. Consider removing that parameter.
ProcedureCanBeWrittenAsFunction

Procedure can be written as a function

A procedure that only has one parameter passed by reference that is assigned a new value/reference before the procedure exits, is using a ByRef parameter as a return value: consider making it a function instead.
ProcedureNotUsed

Procedure is not referred to

Rubberduck could not find any caller for a procedure. If the procedure is hooked to a macro-button, used as a user-defined function (UDF) or handles an application event that Rubberduck didn't know of you can safely ignore this inspection result; otherwise, consider removing it.
RedundantByRefModifier

Redundant 'ByRef' modifier

By default, all parameters are passed by reference, so it is not necessary to include the 'ByRef' modifier.
RedundantOption

Redundant module option

Being the default/implicit setting for this option, this instruction can be safely omitted.
SelfAssignedDeclaration

Object variable reference is auto-instantiated

An auto-instantiated object variable declaration at procedure scope changes how nulling the reference works, which can lead to unexpected behavior.
ShadowedDeclaration

Shadowed declaration

Two declarations are in scope and have the same identifier name. This means that only one of them will be available to use.
SheetAccessedUsingString

Statically accessible sheet accessed using string

Excel already defines a globally scoped object variable with this reference. Consider using the sheet's 'CodeName' property.
StepIsNotSpecified

'For...Next' loop step is not specified

Step of the for-next loop is not specified. This might be unintentional.
StepOneIsRedundant

'For...Next' loop step 1 is redundant

1 is the default step in a for-next loop and therefore is redundant.
StopKeyword

'Stop' keyword

The 'Stop' keyword halts execution and brings up the debugger. Avoid its use in distributed code.
UnassignedVariableUsage

Variable is used but not assigned

This is likely a bug. A variable is being referred to, but is never assigned.
UndeclaredVariable

Undeclared variable

Code that uses undeclared variables does not compile when Option Explicit is specified. Undeclared variables are always Variant, a data type that incurs unnecessary overhead and storage.
UnhandledOnErrorResumeNext

Unhandled 'On Error Resume Next'

Error handling should be restored after using 'On Error Resume Next'.
UnreachableCase

Case Clause(s) cannot be reached

Detects Case Clauses that will never execute.
UntypedFunctionUsage

Use of variant-returning string function

A string-returning equivalent function exists and should preferably be used to avoid implicit type conversions. If the parameter can be null, ignore this inspection result; passing a null value to a function expecting a string would raise a type mismatch runtime error.
UseMeaningfulName

Use meaningful names

Identifier names should indicate what they're used for and should be readable; avoid disemvoweling, numeric suffixes, and 1-2 character names.
VariableNotAssigned

Variable is not assigned

Variable is not assigned. If this isn't intended, there's probably a bug. Ignore this inspection result if the variable is assigned in another procedure via a ByRef parameter.
VariableNotUsed

Variable is not referred to

Variable is not referred to
VariableTypeNotDeclared

Implicitly 'Variant' variable

A variable whose type isn't explicitly declared, is implicitly 'Variant'. Consider making it an explicit 'Variant' if that's intended, or declare a more specific type.
WriteOnlyProperty

Write-only property

A property that exposes a mutator but no accessor is a design smell and makes a confusing API. Consider exposing a getter, or converting the mutator to a method.