rspec/rules/S3603/vbnet/rule.adoc

65 lines
1.1 KiB
Plaintext
Raw Normal View History

2020-06-30 12:48:39 +02:00
include::../description.adoc[]
== How to fix it
2020-06-30 12:48:39 +02:00
=== Code examples
==== Noncompliant code example
[source,vbnet,diff-id=1,diff-type=noncompliant]
2020-06-30 12:48:39 +02:00
----
Class Person
Private age As Integer
<Pure> ' Noncompliant: The method makes a state change
2020-06-30 12:48:39 +02:00
Private Sub ConfigureAge(ByVal age As Integer)
Me.age = age
End Sub
2023-07-03 15:45:51 +02:00
<Pure>
Private Sub WriteAge() ' Noncompliant
Console.WriteLine(Me.age)
End Sub
2020-06-30 12:48:39 +02:00
End Class
----
==== Compliant solution
2020-06-30 12:48:39 +02:00
[source,vbnet,diff-id=1,diff-type=compliant]
2020-06-30 12:48:39 +02:00
----
Class Person
Private age As Integer
Private Sub ConfigureAge(ByVal age As Integer)
Me.age = age
End Sub
2023-07-03 15:45:51 +02:00
<Pure>
Private Function Age() As Integer
Return Me.age
End Function
' or remove Pure attribute from the method
Private Sub WriteAge()
Console.WriteLine(Me.age)
End Sub
2020-06-30 12:48:39 +02:00
End Class
----
2023-07-03 15:45:51 +02:00
include::../resources.adoc[]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
endif::env-github,rspecator-view[]