rspec/rules/S2951/vbnet/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

52 lines
1.1 KiB
Plaintext

== Why is this an issue?
Visual Basic .NET, unlike many other programming languages, has no "fall-through" for its ``++Select++`` cases. Each case already has an implicit ``++Exit Select++`` as its last instruction. It therefore is redundant to explicitly add one.
=== Noncompliant code example
[source,vbnet]
----
Module Module1
Sub Main()
Dim x = 0
Select Case x
Case 0
Console.WriteLine("0")
Exit Select ' Noncompliant
Case Else
Console.WriteLine("Not 0")
Exit Select ' Noncompliant
End Select
End Sub
End Module
----
=== Compliant solution
[source,vbnet]
----
Module Module1
Sub Main()
Dim x = 0
Select Case x
Case 0 ' Compliant
Console.WriteLine("0")
Case Else ' Compliant
Console.WriteLine("Not 0")
End Select
End Sub
End Module
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Remove this redundant use of "Exit Select".
endif::env-github,rspecator-view[]