Inspectopedia
 
2024.3

'return' separated from the result computation

Info
New
Last modified: 03 December 2024

Reports return statements that return a local variable where the value of the variable is computed somewhere else within the same method.

The quick-fix inlines the returned variable by moving the return statement to the location in which the value of the variable is computed. When the returned value can't be inlined into the return statement, the quick-fix attempts to move the return statement as close to the computation of the returned value as possible.

Example:

After the quick-fix is applied: