rspec/rules/S1661/vb6/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

45 lines
860 B
Plaintext

== Why is this an issue?
The local variables in a ``++Static++`` ``++Sub++`` or ``++Function++`` are preserved between calls (meaning that these variables have the same lifetime as the owning module of their procedure). Static procedures should be avoided because they are difficult to test, and can result in unexpected behavior.
=== Noncompliant code example
[source,vb6]
----
Private Static Function Foo() As Single
Dim val As Single ' val retains its value between invocations
val = val + 1
Foo = val
End Function
----
=== Compliant solution
[source,vb6]
----
Private Function Foo() As Single
Dim val As Single
val = val + 1
Foo = val
End Function
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove the static keyword
endif::env-github,rspecator-view[]