The Java rule S4165 complains about a variable assignment to be redundant, which it technically is. But it’s the wrong place to tell. See the following code.
public static String foo( String s )
{
// We may want to do something really smart with this String before returning.
return s;
}
String bar = "bar";
bar = MyClass.foo( bar ); // FP
At the marked line Sonar says, that the assignment is redundant. Yes, it is. But who are we to forsee the implementation of the foo() method? It may change. Do I have to add a NOSONAR tag to any location, where a library decides to change a method’s implementation? Ot should I even change my implementation and remember to change it back when the lib’s changelog tells me, that this method actually does something to the return value again? Not a good idea.
I do agree, that this may be woth to be notified for other cases. But for this case it is definitely FP.