diff --git a/rules/S6146/vb6/rule.adoc b/rules/S6146/vb6/rule.adoc index a53e68a134c..a3828481b42 100644 --- a/rules/S6146/vb6/rule.adoc +++ b/rules/S6146/vb6/rule.adoc @@ -1,12 +1,14 @@ == Why is this an issue? -There are several compilations options available for Visual Basic source code and ``++Option Explicit++`` defines compiler behavior for implicit variable declarations. Not specifying ``++Option Explicit++`` will allow creating a variable by it's first usage. This behavior can lead to unexpected runtime errors due to typos in variable names. +There are several compilations options available for Visual Basic source code and `Option Explicit` defines compiler behavior for implicit variable declarations. Not specifying `Option Explicit` will allow creating a variable by it's first usage. This behavior can lead to unexpected runtime errors due to typos in variable names. +== How to fix it -``++Option Explicit++`` has to be set in individual source files. +`Option Explicit` should be added to every individual source file. +=== Code examples -=== Noncompliant code example +==== Noncompliant code example [source,vb6,diff-id=1,diff-type=noncompliant] ---- @@ -16,14 +18,10 @@ Sub DoSomething(First As String, Second As String) Parametr = Second ' "Second" argument is assigned to newly created variable "Parametr" instead of intended "Parameter". DoSomething(Parameter) ' Value of "Parameter" is always Nothing End Sub - -Sub DoSomething(Parameter As String) - ' ... -End Sub ---- -=== Compliant solution +==== Compliant solution [source,vb6,diff-id=1,diff-type=compliant] ---- @@ -35,8 +33,4 @@ Sub DoSomething(First As String, Second As String) Parameter = Second DoSomething(Parameter) End Sub - -Sub DoSomething(Parameter As String) - ' ... -End Sub ----