Apply suggestions from code review

Co-authored-by: Clément Fournier <clement.fournier@tu-dresden.de>
This commit is contained in:
Andreas Dangel
2024-10-22 20:50:10 +02:00
committed by GitHub
parent 6d55f6f053
commit 09b0864eff

View File

@ -3127,13 +3127,14 @@ public boolean test(String s) {
<rule name="UselessOperationOnImmutable"
language="java"
since="3.5"
message="An operation on an Immutable object (String, BigDecimal, BigInteger or java.time.*) won't change the object itself"
message="The result of an operation on an immutable object is ignored"
class="net.sourceforge.pmd.lang.java.rule.errorprone.UselessOperationOnImmutableRule"
externalInfoUrl="${pmd.website.baseurl}/pmd_rules_java_errorprone.html#uselessoperationonimmutable">
<description>
An operation on an Immutable object (`String`, `BigDecimal`, `BigInteger` or any type from `java.time.*`)
won't change the object itself since the result of the operation is a new object.
Therefore, ignoring the operation result is an error.
An operation on an immutable object will not change the object itself since the result of the operation is a new object.
Therefore, ignoring the result of such an operation is likely a mistake. The operation can probably be removed.
This rule recognizes the types `String`, `BigDecimal`, `BigInteger` or any type from `java.time.*` as immutable.
</description>
<priority>3</priority>
<example>