I'm programming a Controller using Java and I'm checking the style using Sonar. In my Sonar I have an error that says:
'Assignment of Parameter 'variable' is not allowed.
The line that it's on is:
@RequestParam(value="variable", required=false) String variable
So I'm wondering how I could get that error off since I can't just create a setter when I'm using that annotation.
I'm using Eclipse
. The rule being broke is Parameter Assignment
.
@RequestParam(value="variable", required=false) String variable
if (variable != null && variable.compareTo("") == 0) {
variable = null;
}
In your if condition block, you are setting variable to null and it happens to be your method parameter. Instead of assigning the value to the method parameter, create a local variable and use it and return the value of the local variable from the method if at all it is intended.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With