This if block can be removed
236 return modelAndView;
237 } else if (reUser.equals(s1)) {
238 return new ModelAndView("redirect:/home");
239 } else if (reUser.equals(s2)) {240 }241 return modelAndView;
242 }
243}
Description
This method contains a useless control flow statement, where control flow continues onto the same place regardless of whether the branch is taken or not. For example, this is caused by having an empty statement block for an if
statement, or having a conditional that always fails or succeeds:
Bad Practice
// The condition may succeed but nothing happens.
if (argv.length == 0) {
// TODO: handle this case
}
// The condition will always fail.
if (false) {
}
// The condition will always succeed.
if (true) {
}
// A loop with an empty body.
for (int i = 0; i < n; i++) {
}
// ...
Recommended
Remove such if statements if they are not required.
Exceptions
In some cases, loops are used as a way to exhaust or skip over elements in an iterator. This pattern is valid, and the Java analyzer will ignore empty loops where an iterator is updated in the condition.