rspec/rules/S2375/vbnet/rule.adoc

56 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-04-28 16:49:39 +02:00
Using the ``++With++`` statement for a series of calls to the same object makes the code more readable.
2021-04-28 16:49:39 +02:00
== Noncompliant Code Example
With the default value of 6:
2022-02-04 17:28:24 +01:00
[source,vbnet]
2021-04-28 16:49:39 +02:00
----
Module Module1
Dim product = New With {.Name = "paperclips", .RetailPrice = 1.2, .WholesalePrice = 0.6, .A = 0, .B = 0, .C = 0}
Sub Main()
product.Name = "" ' Noncompliant
product.RetailPrice = 0
product.WholesalePrice = 0
product.A = 0
product.B = 0
product.C = 0
End Sub
End Module
----
2021-04-28 16:49:39 +02:00
== Compliant Solution
2022-02-04 17:28:24 +01:00
[source,vbnet]
2021-04-28 16:49:39 +02:00
----
Module Module1
Dim product = New With {.Name = "paperclips", .RetailPrice = 1.2, .WholesalePrice = 0.6, .A = 0, .B = 0, .C = 0}
Sub Main()
With product
.Name = ""
.RetailPrice = 0
.WholesalePrice = 0
.A = 0
.B = 0
.C = 0
End With
End Sub
End Module
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
include::parameters.adoc[]
endif::env-github,rspecator-view[]