Inspectopedia
 
2024.3

Return or assignment can be lifted out

Info
New
Last modified: 03 December 2024

Reports if, when, and try statements that can be converted to expressions by lifting the return statement or an assignment out.

Example:

After the quick-fix is applied:

If you would like this inspection to highlight more complex code with multi-statement branches, uncheck the option "Report only if each branch is a single statement".