rspec/rules/S4487/java/rule.adoc
Egon Okerman d1417e82f8
Modify CWE and OWASP Top 10 links to follow standard link format (APPSEC-1134) (#3529)
* Fix all CWE references

* Fix all OWASP references

* Fix missing CWE prefixes
2024-01-15 17:15:56 +01:00

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[]