rspec/rules/S2583/java/rule.adoc

54 lines
1.1 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
2020-06-30 12:48:07 +02:00
include::../description.adoc[]
include::../noncompliant.adoc[]
=== Exceptions
2020-06-30 12:48:07 +02:00
This rule will not raise an issue in either of these cases:
2021-01-27 13:42:22 +01:00
* When the condition is a single ``++final boolean++``
2020-06-30 12:48:07 +02:00
----
final boolean debug = false;
//...
if (debug) {
// Print something
}
----
2021-01-27 13:42:22 +01:00
* When the condition is literally ``++true++`` or ``++false++``.
2020-06-30 12:48:07 +02:00
----
if (true) {
// do something
}
----
In these cases it is obvious the code is as intended.
== Resources
* https://cwe.mitre.org/data/definitions/570[MITRE, CWE-570] - Expression is Always False
* https://cwe.mitre.org/data/definitions/571[MITRE, CWE-571] - Expression is Always True
* https://wiki.sei.cmu.edu/confluence/x/5dUxBQ[CERT, MSC12-C.] - Detect and remove code that has no effect or is never executed
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[]