48 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

== Why is this an issue?
Doing an operation on a string without using the result of the operation is useless and is certainly due to a misunderstanding.
2020-06-30 12:47:33 +02:00
=== Noncompliant code example
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2020-06-30 12:47:33 +02:00
----
var str = "..."
str.toUpperCase(); // Noncompliant
----
=== Compliant solution
2020-06-30 12:47:33 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2020-06-30 12:47:33 +02:00
----
var str = "..."
str = str.toUpperCase();
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
${objectName} is an immutable object; you must either store or return the result of the operation.
'''
== Comments And Links
(visible only on this page)
=== on 7 Aug 2013, 16:52:44 Freddy Mallet wrote:
Is implemented by \http://jira.codehaus.org/browse/SONARJAVA-242
=== on 27 Feb 2015, 09:27:52 Freddy Mallet wrote:
FYI [~ann.campbell.2], KlockWorks has associated this rule to "CWE-391: Unchecked Error Condition". I'm not convinced by such association but just wanted to notify you: \http://docs.klocwork.com/Insight-10.0/Checkers:RI.IGNOREDCALL
=== on 27 Feb 2015, 16:34:02 Ann Campbell wrote:
\[~freddy.mallet] I'm also (extremely!) unconvinced, but thanks for the notification.
endif::env-github,rspecator-view[]