FP S3077: Immutable objects

SonarJava version 5.9.1

The rule description says that putting volatile on an array or a mutable object is a bad idea. But the rule is triggered on immutable objects as well. Should at least common immutable objects be excluded e.g. String?

1 Like

Agreed – likewise the Java 8 datetime types (which are immutable and thread safe) should be excluded.

As it stands, I’ve fully disabled this rule, as it is far too much noise. Unfortunate. If the rule can be make more intelligent, it might be useful.

Hi,

Thanks for the feedback, I’ve created a ticket to improve this rule.

Can I suggest more classes to be excluded from the analysis? E.g. we have a false positive alert on java.util.UUID, which is immutable

hello @iNikem,

which version of SonarJava analyzer you have? java.util.UUID should be considered from SonarJava 5.14 (latest)

I use SonarCloud. I still cannot find any version indicator there :slight_smile:

SonarCloud always uses the latest version of analyzers. Can you share the link to the issue? If your project is not public, you can create some public project for testing.