rspec/rules/S4487/java/rule.adoc

49 lines
1.0 KiB
Plaintext
Raw Normal View History

== 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;
}
}
----
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;
}
}
----
== Resources
2023-05-29 18:35:17 +02:00
=== Standards
* https://cwe.mitre.org/data/definitions/563[MITRE, 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
2023-06-15 08:54:48 +02:00
include::../rspecator.adoc[]