Method with multiple return points
Reports methods whose number of 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:
Consider rewriting the method so it becomes easier to understand:
Configure the inspection:
Use the Return point limit field to specify the maximum allowed number of
return
points for a method.Use the Ignore guard clauses option to ignore guard clauses. A guard clause is an
if
statement that contains only areturn
statementUse the Ignore for 'equals()' methods option to ignore
return
points insideequals()
methods.
Inspection options
Option | Type | Default |
---|---|---|
Return point limit | Number | 1 |
Ignore guard clauses | Checkbox | false |
Ignore for 'equals()' methods | Checkbox | false |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |