2023-05-03 11:06:20 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2023-06-15 08:54:48 +02:00
|
|
|
include::../why.adoc[]
|
|
|
|
|
|
|
|
[source,java,diff-id=1,diff-type=noncompliant]
|
|
|
|
----
|
|
|
|
public class Rectangle {
|
|
|
|
private int height;
|
|
|
|
private int width; //Noncompliant: width is written but never read
|
|
|
|
|
|
|
|
public Rectangle(int height, int width) {
|
|
|
|
this.height=height;
|
|
|
|
this.width = width;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getArea() {
|
|
|
|
return height * height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
2021-09-21 15:40:35 +02:00
|
|
|
|
2023-05-29 18:35:17 +02:00
|
|
|
{outro}
|
|
|
|
|
2023-06-15 08:54:48 +02:00
|
|
|
[source,java,diff-id=1,diff-type=compliant]
|
|
|
|
----
|
|
|
|
public class Rectangle {
|
|
|
|
private int height;
|
|
|
|
private int width;
|
|
|
|
|
|
|
|
public Rectangle(int height, int width) {
|
|
|
|
this.height=height;
|
|
|
|
this.width = width;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getArea() {
|
|
|
|
return height * width;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
2021-09-21 15:40:35 +02:00
|
|
|
|
2023-05-03 11:06:20 +02:00
|
|
|
== Resources
|
2021-09-21 15:40:35 +02:00
|
|
|
|
2023-05-29 18:35:17 +02:00
|
|
|
=== Standards
|
|
|
|
|
2022-04-07 08:53:59 -05:00
|
|
|
* https://cwe.mitre.org/data/definitions/563[MITRE, CWE-563] - Assignment to Variable without Use ('Unused Variable')
|
2021-09-21 15:40:35 +02:00
|
|
|
* https://wiki.sei.cmu.edu/confluence/x/39UxBQ[CERT, MSC13-C.] - Detect and remove unused values
|
|
|
|
* https://wiki.sei.cmu.edu/confluence/x/9DZGBQ[CERT, MSC56-J.] - Detect and remove superfluous code and values
|
2021-06-02 20:44:38 +02:00
|
|
|
|
2023-06-15 08:54:48 +02:00
|
|
|
include::../rspecator.adoc[]
|