forked from rubberduck-vba/Rubberduck
-
Notifications
You must be signed in to change notification settings - Fork 12
OptionExplicitInspection
Mathieu Guindon edited this page Feb 23, 2015
·
2 revisions
Description: Option Explicit is not specified
Type: CodeInspectionType.CodeQualityIssues
Default severity: CodeInspectionSeverity.Warning
This inspection finds modules that do not specify Option Explicit
###Example:
This module does not specify Option Explicit
Option Private Module
Public Sub DoSomething(foo As Integer)
bar = foo
End Sub
VBA will happily compile and run this code, even though bar
isn't declared anywhere. With Option Explicit
specified, one gets a useful compile-time error about the undeclared variable.
###QuickFixes
QuickFix: Specify Option Explicit
Option Explicit
Option Private Module
Public Sub DoSomething(foo As Integer)
bar = foo ' compile error
End Sub
This quickfix introduces an Option Explicit
instruction at the top of the faulty code module.