
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.
52 lines
1.3 KiB
Plaintext
52 lines
1.3 KiB
Plaintext
== Why is this an issue?
|
|
|
|
include::../description.adoc[]
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,csharp]
|
|
----
|
|
public struct Coordinates
|
|
{
|
|
public int X { get; }
|
|
public int Y { get; }
|
|
|
|
[ExcludeFromCodeCoverage] // Noncompliant
|
|
public override bool Equals(object obj) => obj is Coordinates coordinates && X == coordinates.X && Y == coordinates.Y;
|
|
|
|
[ExcludeFromCodeCoverage] // Noncompliant
|
|
public override int GetHashCode()
|
|
{
|
|
var hashCode = 1861411795;
|
|
hashCode = hashCode * -1521134295 + X.GetHashCode();
|
|
hashCode = hashCode * -1521134295 + Y.GetHashCode();
|
|
return hashCode;
|
|
}
|
|
}
|
|
----
|
|
|
|
=== Compliant solution
|
|
|
|
[source,csharp]
|
|
----
|
|
public struct Coordinates
|
|
{
|
|
public int X { get; }
|
|
public int Y { get; }
|
|
|
|
[ExcludeFromCodeCoverage(Justification = "Code generated by Visual Studio refactoring")] // Compliant
|
|
public override bool Equals(object obj) => obj is Coordinates coordinates && X == coordinates.X && Y == coordinates.Y;
|
|
|
|
[ExcludeFromCodeCoverage(Justification = "Code generated by Visual Studio refactoring")] // Compliant
|
|
public override int GetHashCode()
|
|
{
|
|
var hashCode = 1861411795;
|
|
hashCode = hashCode * -1521134295 + X.GetHashCode();
|
|
hashCode = hashCode * -1521134295 + Y.GetHashCode();
|
|
return hashCode;
|
|
}
|
|
}
|
|
----
|
|
|
|
include::../see.adoc[]
|