diff --git a/rules/S6664/vbnet/compliant.adoc b/rules/S6664/vbnet/compliant.adoc new file mode 100644 index 0000000000..8dcb9ca687 --- /dev/null +++ b/rules/S6664/vbnet/compliant.adoc @@ -0,0 +1,18 @@ + +[source,vbnet,diff-id=1,diff-type=compliant] +---- +Private Sub MyMethod(ByVal items As List(Of MyObject)) + For Each item In items + logger.Debug("Evaluating: {name} which is {availability}", item.Name, If(item.IsAvailable, "available", "not available")) + Try + If item.IsAvailable Then + ' Do stuff + Else + ' Do other stuff + End If + Catch ex As Exception + logger.Error(ex, "Ops! Something happened: ") + End Try + Next +End Sub +---- \ No newline at end of file diff --git a/rules/S6664/vbnet/noncompliant.adoc b/rules/S6664/vbnet/noncompliant.adoc new file mode 100644 index 0000000000..4e86a51836 --- /dev/null +++ b/rules/S6664/vbnet/noncompliant.adoc @@ -0,0 +1,22 @@ + +[source,vbnet,diff-id=1,diff-type=compliant] +---- +Private Sub MyMethod(ByVal items As List(Of MyObject)) + logger.Debug("The operation started") + For Each item In items + Try + If item.IsAvailable Then + ' Do stuff + logger.Debug($"{item.Name} is available") + Else + logger.Debug($"{item.Name} is not available") + ' Do other stuff + End If + Catch ex As Exception + logger.Error("Ops! Something happened") + logger.Error(ex.Message) + End Try + Next + logger.Debug("The operation ended") +End Sub +---- \ No newline at end of file