rspec/rules/S1121/java/rule.adoc

50 lines
1.2 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2020-06-30 12:47:33 +02:00
include::../description.adoc[]
include::../noncompliant.adoc[]
include::../compliant.adoc[]
=== Exceptions
2020-06-30 12:47:33 +02:00
2021-01-27 13:42:22 +01:00
Assignments in ``++while++`` statement conditions, and assignments enclosed in relational expressions are ignored.
2020-06-30 12:47:33 +02:00
----
BufferedReader br = new BufferedReader(/* ... */);
String line;
while ((line = br.readLine()) != null) {...}
if ((i = j) >= 1) {...}
2020-06-30 12:47:33 +02:00
----
Chained assignments, including compound assignments, are ignored.
2020-06-30 12:47:33 +02:00
----
int i = j = 0;
int k = (j += 1);
result = (bresult = new byte[len]);
----
== Resources
* https://cwe.mitre.org/data/definitions/481[MITRE, CWE-481] - Assigning instead of Comparing
* https://wiki.sei.cmu.edu/confluence/x/ZNYxBQ[CERT, EXP45-C.] - Do not perform assignments in selection statements
* https://wiki.sei.cmu.edu/confluence/x/ITZGBQ[CERT, EXP51-J.] - Do not perform assignments in conditional expressions
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
include::../highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]