49 lines
1.0 KiB
Plaintext
49 lines
1.0 KiB
Plaintext
== Why is this an issue?
|
|
|
|
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;
|
|
}
|
|
}
|
|
----
|
|
|
|
{outro}
|
|
|
|
[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;
|
|
}
|
|
}
|
|
----
|
|
|
|
== Resources
|
|
|
|
=== Standards
|
|
|
|
* CWE - https://cwe.mitre.org/data/definitions/563[CWE-563 - Assignment to Variable without Use ('Unused Variable')]
|
|
* 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
|
|
|
|
include::../rspecator.adoc[] |