
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
66 lines
1.9 KiB
Plaintext
66 lines
1.9 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,vbnet]
|
|
----
|
|
Public Structure Coordinates
|
|
|
|
Public ReadOnly Property X As Integer
|
|
Public ReadOnly Property Y As Integer
|
|
|
|
<ExcludeFromCodeCoverage> ' Noncompliant
|
|
Public Overrides Function Equals(obj As Object) As Boolean
|
|
If Not (TypeOf obj Is Coordinates) Then
|
|
Return False
|
|
End If
|
|
|
|
Dim coordinates = DirectCast(obj, Coordinates)
|
|
Return X = coordinates.X AndAlso
|
|
Y = coordinates.Y
|
|
End Function
|
|
|
|
<ExcludeFromCodeCoverage> ' Noncompliant
|
|
Public Overrides Function GetHashCode() As Integer
|
|
Dim hashCode As Long = 1861411795
|
|
hashCode = (hashCode * -1521134295 + X.GetHashCode()).GetHashCode()
|
|
hashCode = (hashCode * -1521134295 + Y.GetHashCode()).GetHashCode()
|
|
Return hashCode
|
|
End Function
|
|
End Structure
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,vbnet]
|
|
----
|
|
Public Structure Coordinates
|
|
|
|
Public ReadOnly Property X As Integer
|
|
Public ReadOnly Property Y As Integer
|
|
|
|
<ExcludeFromCodeCoverage(Justification:="Code generated by Visual Studio refactoring")> ' Compliant
|
|
Public Overrides Function Equals(obj As Object) As Boolean
|
|
If Not (TypeOf obj Is Coordinates) Then
|
|
Return False
|
|
End If
|
|
|
|
Dim coordinates = DirectCast(obj, Coordinates)
|
|
Return X = coordinates.X AndAlso
|
|
Y = coordinates.Y
|
|
End Function
|
|
|
|
<ExcludeFromCodeCoverage(Justification:="Code generated by Visual Studio refactoring")> ' Compliant
|
|
Public Overrides Function GetHashCode() As Integer
|
|
Dim hashCode As Long = 1861411795
|
|
hashCode = (hashCode * -1521134295 + X.GetHashCode()).GetHashCode()
|
|
hashCode = (hashCode * -1521134295 + Y.GetHashCode()).GetHashCode()
|
|
Return hashCode
|
|
End Function
|
|
End Structure
|
|
----
|
|
|
|
include::../see.adoc[]
|