public static final Map<String, ArrayList<Command>> customCommands = new HashMap<>();
public static final Map<String, ArrayList<Command>> coreCommands = new HashMap<>();
I have these two lines in my code. These are fields of a class. Even though they are declared as final, Sonarlint gives a positive for rule java:S2386 "Mutable fields should not be "public static"".
I'm working in Eclipse IDE using JDK 13. Sonarlint's version is 5.0.
Even if they were final, the collection itself is still mutable. I believe Sonar would not report an issue if they were wrapped via Collections.unmodifiableMap(), but you would need to adapt your code so that all values are assigned at initialization of the variables.
Iām using java 11ās Map.ofEntries(entry(), entry()ā¦);
This utility returns an unmodifiable map, but SonarLint still complains to make it protected
Since your problem is targetting another case and the initial question is marked with a solution, the good way to go would indeed be to create a new post. It will help to not go unnoticed for too long.
In this case, no need to create another one, I agree with you and created a ticket thanks to your feedback (SONARJAVA-3429).