65 lines
1.1 KiB
Plaintext
65 lines
1.1 KiB
Plaintext
include::../description.adoc[]
|
|
|
|
== How to fix it
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,vbnet,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
Class Person
|
|
Private age As Integer
|
|
|
|
<Pure> ' Noncompliant: The method makes a state change
|
|
Private Sub ConfigureAge(ByVal age As Integer)
|
|
Me.age = age
|
|
End Sub
|
|
|
|
<Pure>
|
|
Private Sub WriteAge() ' Noncompliant
|
|
Console.WriteLine(Me.age)
|
|
End Sub
|
|
|
|
End Class
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,vbnet,diff-id=1,diff-type=compliant]
|
|
----
|
|
Class Person
|
|
Private age As Integer
|
|
|
|
Private Sub ConfigureAge(ByVal age As Integer)
|
|
Me.age = age
|
|
End Sub
|
|
|
|
<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
|
|
|
|
End Class
|
|
----
|
|
|
|
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[]
|