Here's the hashCode() method that Eclipse has kindly generated for me:
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + (int) (id ^ (id >>> 32)); return result; }
When I run findbugs on this, it complains about the last line:
The method ... hashCode () saves the result of returning to local before returning immediately [Scariest (2), Normal Confidence]
Who is there? Findbugs or Eclipse? Is it dodgy?
I canβt understand for life why this is something for findbugs to get upset. The code is perfectly clear; keeping it in local mode before returning it does not make it difficult to read or more difficult to maintain; and if the compiler is not very poorly written, it will also not affect performance.
And yet it is classified as Scariest !
Did I miss something?
(Obviously, the code can be simplified in some respects, and this is because, with respect to Eclipse, there might be other fields included in the hash function, but in particular the problem of storing the value and then immediately returning it, which I ask here because what the error spoons complain about.)
java eclipse local-variables findbugs
chiastic-security
source share