As an alternative to littering my code with thousands of final keywords in front of my parameters, I'm trying to enforce it using FindBugs.
It doesn't seem possible to do this, but there should be a way, shouldn't there?
Thanks
As an alternative to littering my code with thousands of final keywords in front of my parameters, I'm trying to enforce it using FindBugs.
It doesn't seem possible to do this, but there should be a way, shouldn't there?
Thanks
Findbugs has one related bug pattern:
IP: A parameter is dead upon entry to a method but overwritten (IP_PARAMETER_IS_DEAD_BUT_OVERWRITTEN)
The initial value of this parameter is ignored, and the parameter is overwritten here. This often indicates a mistaken belief that the write to the parameter will be conveyed back to the caller.
However, I don't think this will catch instances where you overwrite the param after reading the param somewhere.
On the other hand, it looks like PMD does have a rule that is exactly what you're looking for:
AvoidReassigningParameters: Reassigning values to parameters is a questionable practice. Use a temporary local variable instead.
And if that doesn't work for you, the PMD people have a list of many more static checkers, both free and commercial that you could look into.