Skip to content

Commit

Permalink
Add description
Browse files Browse the repository at this point in the history
  • Loading branch information
thahnen committed Dec 18, 2024
1 parent 9a006b9 commit 77ec01e
Showing 1 changed file with 27 additions and 29 deletions.
56 changes: 27 additions & 29 deletions rules/S6146/vb6/rule.adoc
Original file line number Diff line number Diff line change
@@ -1,44 +1,42 @@
FIXME: add a description

// If you want to factorize the description uncomment the following line and create the file.
//include::../description.adoc[]

== Why is this an issue?

FIXME: remove the unused optional headers (that are commented out)
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.

//=== What is the potential impact?

== How to fix it
//== How to fix it in FRAMEWORK NAME
``++Option Explicit++`` has to be set in individual source files.

=== Code examples

==== Noncompliant code example
=== Noncompliant code example

[source,vb6,diff-id=1,diff-type=noncompliant]
----
FIXME
Sub DoSomething(First As String, Second As String)
Parameter = Fist ' New local variable "Fist" is created and assigned to new local variable "Parameter" instead of "First" argument.
DoSomething(Parameter)
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]
----
FIXME
Option Explicit
Sub DoSomething(First As String, Second As String)
Dim Parameter As String = First
DoSomething(Parameter)
Parameter = Second
DoSomething(Parameter)
End Sub
Sub DoSomething(Parameter As String)
' ...
End Sub
----

//=== How does this work?

//=== Pitfalls

//=== Going the extra mile


//== Resources
//=== Documentation
//=== Articles & blog posts
//=== Conference presentations
//=== Standards
//=== External coding guidelines
//=== Benchmarks

0 comments on commit 77ec01e

Please sign in to comment.