Source:
<code>public void reAssignActors(UpdatableProcessInstance instance, Actor[] unAssignedActors, Actor[] assignedActors, User user) throws WorkflowException { ProcessInstanceManager instanceManager = WorkflowHub.getProcessInstanceManager(); String id = instance.getInstanceId(); Mutable<UpdatableHistoryStep> step = Mutable.of(null); Transaction.performInOne(()-> { UpdatableProcessInstance processInstance = repository.getById(id); UpdatableHistoryStep newStep = (UpdatableHistoryStep) instanceManager.createHistoryStep(); newStep.setUserId(user.getUserId()); newStep.setAction("#reAssign#"); newStep.setActionDate(new Date()); newStep.setUserRoleName("supervisor"); newStep.setResolvedState("DummyStateFromReassignment"); newStep.setActionStatus(0); newStep.setProcessInstance(processInstance); historyStepRepository.save((HistoryStepImpl) newStep); step.set(newStep); return newStep; }); instance.addHistoryStep(step.get()); <START> Transaction.performInOne(()-> { <END> UpdatableProcessInstance processInstance = repository.getById(id); UpdatableHistoryStep currentStep = (UpdatableHistoryStep) processInstance.getHistoryStep(step.get().getId()); processInstance.updateHistoryStep(currentStep); TaskManager taskManager = WorkflowHub.getTaskManager(); Task[] tasks = taskManager.createTasks(unAssignedActors, processInstance); for (final Task task : tasks) { taskManager.unAssignTask(task); } for (final Actor unAssignedActor : unAssignedActors) { processInstance.removeWorkingUser(unAssignedActor.getUser(), unAssignedActor.getState(), unAssignedActor.getUserRoleName()); } tasks = taskManager.createTasks(assignedActors, processInstance); for (final Task task : tasks) { taskManager.assignTask(task, user); } for (final Actor assignedActor : assignedActors) { processInstance.addWorkingUser(assignedActor.getUser(), assignedActor.getState(), assignedActor.getUserRoleName()); } currentStep.setActionStatus(2); processInstance.updateHistoryStep(currentStep); repository.save((ProcessInstanceImpl) processInstance); return null; }); }</code><technical_language>![MAJOR](<LINK_1> 'Severity: MAJOR') Reduce this lambda expression number of lines 27 20. [![rule](<LINK_2>](<LINK_0></technical_language>

Target:
public void reAssignActors(UpdatableProcessInstance instance, Actor[] unAssignedActors, Actor[] assignedActors, User user) throws WorkflowException { ProcessInstanceManager instanceManager = WorkflowHub.getProcessInstanceManager(); String id = instance.getInstanceId(); Mutable<UpdatableHistoryStep> step = Mutable.of(null); Transaction.performInOne(()-> { UpdatableProcessInstance processInstance = repository.getById(id); UpdatableHistoryStep newStep = (UpdatableHistoryStep) instanceManager.createHistoryStep(); newStep.setUserId(user.getUserId()); newStep.setAction("#reAssign#"); newStep.setActionDate(new Date()); newStep.setUserRoleName("supervisor"); newStep.setResolvedState("DummyStateFromReassignment"); newStep.setActionStatus(0); newStep.setProcessInstance(processInstance); historyStepRepository.save((HistoryStepImpl) newStep); step.set(newStep); return newStep; }); instance.addHistoryStep(step.get()); Transaction.performInOne(()-> { UpdatableProcessInstance processInstance = repository.getById(id); UpdatableHistoryStep currentStep = (UpdatableHistoryStep) processInstance.getHistoryStep(step.get().getId()); processInstance.updateHistoryStep(currentStep); TaskManager taskManager = WorkflowHub.getTaskManager(); Task[] tasks = taskManager.createTasks(unAssignedActors, processInstance); for (final Task task : tasks) { taskManager.unAssignTask(task); } for (final Actor unAssignedActor : unAssignedActors) { processInstance.removeWorkingUser(unAssignedActor.getUser(), unAssignedActor.getState(), unAssignedActor.getUserRoleName()); } tasks = taskManager.createTasks(assignedActors, processInstance); for (final Task task : tasks) { taskManager.assignTask(task, user); } for (final Actor assignedActor : assignedActors) { processInstance.addWorkingUser(assignedActor.getUser(), assignedActor.getState(), assignedActor.getUserRoleName()); } currentStep.setActionStatus(UpdatableHistoryStep.ACTION_STATUS_AFFECTATIONSDONE); processInstance.updateHistoryStep(currentStep); repository.save((ProcessInstanceImpl) processInstance); return null; }); }