rspec/rules/S4487/csharp/rule.adoc
2023-06-19 09:42:33 +02:00

59 lines
938 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 * width;
}
}
}
----
{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
* https://cwe.mitre.org/data/definitions/563[MITRE, CWE-563] - Assignment to Variable without Use ('Unused Variable')
include::../rspecator.adoc[]