Both S2441 and S2118 needs to know whether an object is serializable or not, in the current situation, both rules have different way of determining it, but none of them is ideal, leading to FP in both rules.
- FP in S2441:
Looks like in
SONARJAVA-1810we excluded collections like sets and arrays, still we report FP on variable declared as Map and assigned instance of HashMap.
S2188 faced this issue and solve it in
SONARJAVA-3023. Since it requires a final variable, it does not seem to be ideal.
- FP in S2118:
S2118 only supports Map and HashMap, but not the others usual collections
We should refactor the code to have a better detection of serializable and to allow both rule to share this information.