rspec/rules/S4487/csharp/rule.adoc

60 lines
940 B
Plaintext
Raw Normal View History

== 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;
}
2020-06-30 12:49:37 +02:00
public int Surface
{
get
{
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;
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
2023-06-15 08:54:48 +02:00
=== Standards
* CWE - https://cwe.mitre.org/data/definitions/563[CWE-563 - Assignment to Variable without Use ('Unused Variable')]
include::../rspecator.adoc[]