I am using SonarQube 6.7.3 with Sonar java plugin 5.3
I have a Serializable java class with a map as an instance variable. 1. Map is showing S1948 rule violation when initialized with null explicitly. 2. Map is not showing any violation when that explicit null initialization is removed.
Same can be seen below screenshot. Can you help me understand the difference between the two.
Some implementations of Map are serializable, others are not. So if you initialize it as a null, it will raise the rule as Sonar doesn't have a way to know what implementation you're going to use.
This post has it all explained: Java why a Map of Map (ex: Map<String,Map<String,String>>) not serializeable