rspec/rules/S4487/csharp/rule.adoc
2025-01-31 15:47:52 +01:00

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[]