void (@NotNull final PsiMethod method) { final PsiReturnStatement[] statements = PsiUtil.findReturnStatements(method); if (statements.length > 0) { for (int i = statements.length - 1; i >= 0; i--) { PsiReturnStatement returnStatement = statements[i]; try { final PsiExpression expression = returnStatement.getReturnValue(); if (expression != null) { List<PsiExpression> sideEffectExpressions = SideEffectChecker.extractSideEffectExpressions(expression); PsiStatement[] sideEffectStatements = StatementExtractor.generateStatements(sideEffectExpressions, expression); if (sideEffectStatements.length > 0) { PsiStatement added = BlockUtils.addBefore(returnStatement, sideEffectStatements); returnStatement = PsiTreeUtil.getNextSiblingOfType(added, PsiReturnStatement.class); } if (returnStatement != null && returnStatement.getReturnValue() != null) { returnStatement.getReturnValue().delete(); if (UnnecessaryReturnInspection.isReturnRedundant(returnStatement, false, true, null)) { returnStatement.delete(); } } } } catch (IncorrectOperationException e) { LOG.error(e); } } } }