return
points exceeds the specified maximum.
Methods with too many return
points may be confusing
and hard to refactor.
A return
point is either a return
statement or a falling through the bottom of a
void
method or constructor.
Example:
The method below is reported if only two return
statements are allowed:
void doSmth(User[] users) {
for (User user : users) {
if (cond1(user)) {
user.setId(getId());
return;
} else if (cond2(user)) {
if (cond3(user)) {
user.setId(getId());
return;
}
}
}
}
Consider rewriting the method so it becomes easier to understand:
void doSmth(User[] users) {
for (User user : users) {
if (cond1(user) || cond2(user) && cond3(user)) {
user.setId(getId());
return;
}
}
}
Configure the inspection:
return
points for a method.if
statement that contains only a return
statementreturn
points inside equals()
methods.