60 lines
940 B
Plaintext
60 lines
940 B
Plaintext
== Why is this an issue?
|
|
|
|
include::../why.adoc[]
|
|
|
|
[source,csharp,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
public class Rectangle
|
|
{
|
|
private readonly int length;
|
|
private readonly int width; // Noncompliant: width is written but never read
|
|
|
|
public Rectangle(int length, int width)
|
|
{
|
|
this.length = length;
|
|
this.width = width;
|
|
}
|
|
|
|
public int Surface
|
|
{
|
|
get
|
|
{
|
|
return length * length;
|
|
}
|
|
}
|
|
}
|
|
----
|
|
|
|
{outro}
|
|
|
|
[source,csharp,diff-id=1,diff-type=compliant]
|
|
----
|
|
public class Rectangle
|
|
{
|
|
private readonly int length;
|
|
private readonly int width;
|
|
|
|
public Rectangle(int length, int width)
|
|
{
|
|
this.length = length;
|
|
this.width = width;
|
|
}
|
|
|
|
public int Surface
|
|
{
|
|
get
|
|
{
|
|
return length * width;
|
|
}
|
|
}
|
|
}
|
|
----
|
|
|
|
== Resources
|
|
|
|
=== Standards
|
|
|
|
* CWE - https://cwe.mitre.org/data/definitions/563[CWE-563 - Assignment to Variable without Use ('Unused Variable')]
|
|
|
|
include::../rspecator.adoc[]
|