27 lines
839 B
Plaintext
27 lines
839 B
Plaintext
=== Exceptions
|
|
|
|
Blocks in an `If` chain or `Case` clause that contain a single line of code are ignored.
|
|
|
|
[source,vbnet]
|
|
----
|
|
If a >= 0 AndAlso a < 10 Then
|
|
DoTheThing()
|
|
ElseIf a >= 10 AndAlso a < 20 Then
|
|
DoTheOtherThing()
|
|
ElseIf a >= 20 AndAlso a < 50 ' no issue, usually this is done on purpose to increase the readability
|
|
DoTheThing()
|
|
End If
|
|
----
|
|
|
|
But this exception does not apply to `If` chains without `Else`-s, or to `Select`-s without `Case Else` clauses when all branches have the same single line of code. In the case of `If` chains with `Else`-s, or of `Select`-es with `Case Else` clauses, rule S3923 raises a bug.
|
|
|
|
|
|
[source,vbnet]
|
|
----
|
|
If a >= 0 AndAlso a < 10 Then
|
|
DoTheThing()
|
|
ElseIf a >= 10 AndAlso a < 20 Then
|
|
DoTheOtherThing() ' Noncompliant, this might have been done on purpose but probably not
|
|
End If
|
|
----
|