Marking a method with the Pure
attribute indicates that the method doesn’t make any visible state changes. Therefore, a Pure method should return a result otherwise it
indicates a no-operation call.
Using Pure on a void method is either by mistake or the method is not doing a meaningful task.
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
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