Skip to content

Commit

Permalink
reduce cognitive complexity
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu DEHARBE <[email protected]>
  • Loading branch information
Mathieu-Deharbe committed Sep 4, 2024
1 parent 6f7a6ae commit 6e29fdc
Showing 1 changed file with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,32 +436,40 @@ private static void processTapchangerSteps(List<ReportNode> tapChangerStepsRepor
addStepAttributeReports(tapChangerStepsReports, step);
}
if (tapChangerStepReplacer instanceof RatioTapChangerStepsReplacer || tapChangerAdder instanceof RatioTapChangerAdder) {
if (isModification) {
tapChangerStepReplacer.beginStep().setR(step.getR()).setX(step.getX()).setG(step.getG())
.setB(step.getB()).setRho(step.getRho()).endStep();
} else {
tapChangerAdder.beginStep().setR(step.getR()).setX(step.getX()).setG(step.getG())
.setB(step.getB()).setRho(step.getRho()).endStep();
}
processRatioTapChangerStep(tapChangerAdder, tapChangerStepReplacer, isModification, step);
} else {
if (tapChangerStepsReports != null) {
addStepAttributeReport(tapChangerStepsReports, "newStepAlpha" + step.getAlpha(),
" Shift angle : ${alpha}", "alpha", String.valueOf(step.getAlpha()));
}
if (isModification) {
((PhaseTapChangerStepsReplacer) tapChangerStepReplacer).beginStep().setR(step.getR()).setX(step.getX()).setG(step.getG())
.setB(step.getB()).setRho(step.getRho()).setAlpha(step.getAlpha()).endStep();
} else {
((PhaseTapChangerAdder) tapChangerAdder).beginStep().setR(step.getR()).setX(step.getX()).setG(step.getG())
.setB(step.getB()).setRho(step.getRho()).setAlpha(step.getAlpha()).endStep();
}
processPhaseTapChangerStep(tapChangerStepsReports, (PhaseTapChangerAdder) tapChangerAdder, (PhaseTapChangerStepsReplacer) tapChangerStepReplacer, isModification, step);
}
}
if (isModification) {
tapChangerStepReplacer.replaceSteps();
}
}

private static void processPhaseTapChangerStep(List<ReportNode> tapChangerStepsReports, PhaseTapChangerAdder tapChangerAdder, PhaseTapChangerStepsReplacer tapChangerStepReplacer, boolean isModification, TapChangerStepCreationInfos step) {
if (tapChangerStepsReports != null) {
addStepAttributeReport(tapChangerStepsReports, "newStepAlpha" + step.getAlpha(),
" Shift angle : ${alpha}", "alpha", String.valueOf(step.getAlpha()));
}
if (isModification) {
tapChangerStepReplacer.beginStep().setR(step.getR()).setX(step.getX()).setG(step.getG())
.setB(step.getB()).setRho(step.getRho()).setAlpha(step.getAlpha()).endStep();
} else {
tapChangerAdder.beginStep().setR(step.getR()).setX(step.getX()).setG(step.getG())
.setB(step.getB()).setRho(step.getRho()).setAlpha(step.getAlpha()).endStep();
}
}

private static void processRatioTapChangerStep(TapChangerAdder<?, ?, ?, ?, ?, ?> tapChangerAdder, TapChangerStepsReplacer<?, ?> tapChangerStepReplacer, boolean isModification, TapChangerStepCreationInfos step) {
if (isModification) {
tapChangerStepReplacer.beginStep().setR(step.getR()).setX(step.getX()).setG(step.getG())
.setB(step.getB()).setRho(step.getRho()).endStep();
} else {
tapChangerAdder.beginStep().setR(step.getR()).setX(step.getX()).setG(step.getG())
.setB(step.getB()).setRho(step.getRho()).endStep();
}
}

private static void addStepAttributeReports(List<ReportNode> tapChangerStepsReports, TapChangerStepCreationInfos step) {
addStepAttributeReport(tapChangerStepsReports, "newStepIndex" + step.getIndex(),
" Tap (${index})", "index", String.valueOf(step.getIndex()));
Expand Down

0 comments on commit 6e29fdc

Please sign in to comment.