rspec/rules/S5856/vbnet/rule.adoc
Fred Tingaud 51369b610e
Make sure that includes are always surrounded by empty lines (#2270)
When an include is not surrounded by empty lines, its content is inlined
on the same line as the adjacent content. That can lead to broken tags
and other display issues.
This PR fixes all such includes and introduces a validation step that
forbids introducing the same problem again.
2023-06-22 10:38:01 +02:00

34 lines
1.0 KiB
Plaintext

include::../why-dotnet.adoc[]
== How to fix it
=== Code examples
==== Noncompliant code example
[source,vbnet,diff-id=1,diff-type=noncompliant]
----
Sub Regexes(Input As String)
Dim Rx As New Regex("[A") ' Noncompliant: unmatched "["
Dim Match = Regex.Match(Input, "[A") ' Noncompliant
Dim NegativeLookahead As New Regex("a(?!b)", RegexOptions.NonBacktracking) ' Noncompliant: negative lookahead without backtracking
Dim NegativeLookbehind As New Regex("(?<!a)b", RegexOptions.NonBacktracking) ' Noncompliant: negative lookbehind without backtracking
End Sub
----
==== Compliant solution
[source,vbnet,diff-id=1,diff-type=compliant]
----
Sub Regexes(Input As String)
Dim Rx As New Regex("[A-Z]")
Dim Match = Regex.Match(Input, "[A-Z]")
Dim NegativeLookahead As New Regex("a(?!b)")
Dim NegativeLookbehind As New Regex("(?<!a)b")
End Sub
----
include::../resources-dotnet.adoc[]
include::../rspecator.adoc[]