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:
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
MethodWithMultipleReturnPoints- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Configure the inspection:
Use the Return point limit field to specify the maximum allowed number of
returnpoints for a method.Use the Ignore guard clauses option to ignore guard clauses. A guard clause is an
ifstatement that contains only areturnstatementUse the Ignore for 'equals()' methods option to ignore
returnpoints insideequals()methods.
Inspection options
Here you can find the description of settings available for the Method with multiple return points inspection, and the reference of their default values.
- Return point limit
Default value:
1- Ignore guard clauses
Default value:
Not selected- Ignore for 'equals()' methods
Default value:
Not selected
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |