rspec/rules/S3346/java/rule.adoc
Fred Tingaud 6f24cc0632
Clean rule at root
In some cases, the `rule.adoc` at root of a rule is never included
anywhere and thus is dead code.
It's a maintenance cost by itself, but also it misses opportunities to
inline code that seems used by two documents when in fact only one
document is actually rendered. And this missed opportunity, in turn,
stops us from applying the correct language tag on the code samples.
2023-10-16 16:34:38 +02:00

47 lines
937 B
Plaintext

== Why is this an issue?
Since ``++assert++`` statements aren't executed by default (they must be enabled with JVM flags) developers should never rely on their execution the evaluation of any logic required for correct program function.
=== Noncompliant code example
[source,java]
----
assert myList.remove(myList.get(0)); // Noncompliant
----
=== Compliant solution
[source,java]
----
boolean removed = myList.remove(myList.get(0));
assert removed;
----
== Resources
* https://wiki.sei.cmu.edu/confluence/x/mjdGBQ[CERT, EXP06-J.] - Expressions used in assertions must not produce side effects
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Move this "assert" side effect to another statement.
include::../highlighting.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]