2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2023-06-15 08:54:48 +02:00
|
|
|
include::../why.adoc[]
|
2020-06-30 12:49:37 +02:00
|
|
|
|
2023-05-29 18:35:17 +02:00
|
|
|
[source,csharp,diff-id=1,diff-type=noncompliant]
|
2020-06-30 12:49:37 +02:00
|
|
|
----
|
|
|
|
public class Rectangle
|
|
|
|
{
|
|
|
|
private readonly int length;
|
2023-05-29 18:35:17 +02:00
|
|
|
private readonly int width; // Noncompliant: width is written but never read
|
2020-06-30 12:49:37 +02:00
|
|
|
|
|
|
|
public Rectangle(int length, int width)
|
|
|
|
{
|
|
|
|
this.length = length;
|
|
|
|
this.width = width;
|
2025-01-31 15:47:52 +01:00
|
|
|
}
|
2020-06-30 12:49:37 +02:00
|
|
|
|
|
|
|
public int Surface
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2025-01-31 15:47:52 +01:00
|
|
|
return length * length;
|
2020-06-30 12:49:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2023-05-29 18:35:17 +02:00
|
|
|
{outro}
|
2020-06-30 12:49:37 +02:00
|
|
|
|
2023-05-29 18:35:17 +02:00
|
|
|
[source,csharp,diff-id=1,diff-type=compliant]
|
2020-06-30 12:49:37 +02:00
|
|
|
----
|
|
|
|
public class Rectangle
|
|
|
|
{
|
|
|
|
private readonly int length;
|
|
|
|
private readonly int width;
|
|
|
|
|
|
|
|
public Rectangle(int length, int width)
|
|
|
|
{
|
|
|
|
this.length = length;
|
2023-06-16 15:42:30 +02:00
|
|
|
this.width = width;
|
2020-06-30 12:49:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int Surface
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
return length * width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
2023-06-15 08:54:48 +02:00
|
|
|
== Resources
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2023-06-15 08:54:48 +02:00
|
|
|
=== Standards
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2024-01-15 17:15:56 +01:00
|
|
|
* CWE - https://cwe.mitre.org/data/definitions/563[CWE-563 - Assignment to Variable without Use ('Unused Variable')]
|
2021-09-20 15:38:42 +02:00
|
|
|
|
2025-01-31 15:47:52 +01:00
|
|
|
include::../rspecator.adoc[]
|