From 13755ff998fa4fe77e0b973a3d8f5a657389b2e5 Mon Sep 17 00:00:00 2001 From: Florian Dupuy Date: Mon, 25 Mar 2024 13:54:19 +0100 Subject: [PATCH] Fix code smells Signed-off-by: Florian Dupuy --- .../com/powsybl/diagram/test/Networks.java | 18 +++++------ .../sld/layout/ImplicitCellDetector.java | 9 ------ .../PositionVoltageLevelLayoutFactory.java | 2 +- .../sld/raw/TestCase7CellDetectionIssue.java | 2 +- ...neLegInternCellDifferentSubsectionsLbs.svg | 12 +++---- ...OneLegInternCellDifferentSubsectionsSi.svg | 32 +++++++++---------- 6 files changed, 33 insertions(+), 42 deletions(-) diff --git a/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java b/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java index 2999d9977..250e638cb 100644 --- a/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java +++ b/diagram-test/src/main/java/com/powsybl/diagram/test/Networks.java @@ -2236,9 +2236,9 @@ public static Network createNetworkWithComplexInternCellDifferentSubsections1() Networks.createLoad(voltageLevel, "load", "load", "load", null, ConnectablePosition.Direction.TOP, 3, 10d, 10d); Networks.createSwitch(voltageLevel, "dl11", "dl111", SwitchKind.DISCONNECTOR, false, false, false, 0, 3); Networks.createSwitch(voltageLevel, "dl121", "dl12", SwitchKind.DISCONNECTOR, false, true, false, 1, 3); - Networks.createSwitch(voltageLevel, "d11", "d11", SwitchKind.DISCONNECTOR, false, false, false, 0, 4); - Networks.createSwitch(voltageLevel, "d12", "d12", SwitchKind.DISCONNECTOR, false, false, false, 1, 4); - Networks.createSwitch(voltageLevel, "d21", "d21", SwitchKind.DISCONNECTOR, false, false, false, 2, 4); + Networks.createSwitch(voltageLevel, "d11", "d11", SwitchKind.DISCONNECTOR, false, false, false, 0, 11); + Networks.createSwitch(voltageLevel, "d12", "d12", SwitchKind.DISCONNECTOR, false, true, false, 1, 11); + Networks.createSwitch(voltageLevel, "d21", "d21", SwitchKind.DISCONNECTOR, false, false, false, 2, 11); return network; } @@ -2252,14 +2252,14 @@ public static Network createNetworkWithComplexInternCellDifferentSubsections() { Networks.createBusBarSection(voltageLevel, "1.2", "1.2", 1, 2, 1); Networks.createBusBarSection(voltageLevel, "2.1", "2.1", 2, 1, 2); - Networks.createLoad(voltageLevel, "load0", "load0", "load0", null, ConnectablePosition.Direction.TOP, 3, 10d, 10d); - Networks.createSwitch(voltageLevel, "dl0", "dl0", SwitchKind.DISCONNECTOR, false, false, false, 0, 3); - Networks.createLoad(voltageLevel, "load2", "load2", "load2", null, ConnectablePosition.Direction.TOP, 4, 10d, 10d); + Networks.createLoad(voltageLevel, LOAD_1_ID, LOAD_1_ID, LOAD_1_ID, null, ConnectablePosition.Direction.TOP, 3, 10d, 10d); + Networks.createSwitch(voltageLevel, "dl1", "dl1", SwitchKind.DISCONNECTOR, false, false, false, 0, 3); + Networks.createLoad(voltageLevel, LOAD_2_ID, LOAD_2_ID, LOAD_2_ID, null, ConnectablePosition.Direction.TOP, 4, 10d, 10d); Networks.createSwitch(voltageLevel, "dl2", "dl2", SwitchKind.DISCONNECTOR, false, false, false, 2, 4); - Networks.createSwitch(voltageLevel, "d0", "d0", SwitchKind.DISCONNECTOR, false, true, false, 0, 11); - Networks.createSwitch(voltageLevel, "d1", "d1", SwitchKind.DISCONNECTOR, false, false, false, 1, 11); - Networks.createSwitch(voltageLevel, "d2", "d2", SwitchKind.DISCONNECTOR, false, false, false, 2, 11); + Networks.createSwitch(voltageLevel, "d11", "d11", SwitchKind.DISCONNECTOR, false, true, false, 0, 11); + Networks.createSwitch(voltageLevel, "d12", "d12", SwitchKind.DISCONNECTOR, false, false, false, 1, 11); + Networks.createSwitch(voltageLevel, "d21", "d21", SwitchKind.DISCONNECTOR, false, false, false, 2, 11); return network; } diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/layout/ImplicitCellDetector.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/layout/ImplicitCellDetector.java index a7ce7b332..7a17df6ef 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/layout/ImplicitCellDetector.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/layout/ImplicitCellDetector.java @@ -31,15 +31,6 @@ public class ImplicitCellDetector implements CellDetector { private static final Logger LOGGER = LoggerFactory.getLogger(ImplicitCellDetector.class); - private final boolean exceptionIfPatternNotHandled; - - public ImplicitCellDetector(boolean exceptionIfPatternNotHandled) { - this.exceptionIfPatternNotHandled = exceptionIfPatternNotHandled; - } - - public ImplicitCellDetector() { - this(false); - } /** * internCell detection : an internal cell is composed of nodes connecting BUSes without connecting Feeder. diff --git a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/layout/PositionVoltageLevelLayoutFactory.java b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/layout/PositionVoltageLevelLayoutFactory.java index 95c3eb6e1..32287891c 100644 --- a/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/layout/PositionVoltageLevelLayoutFactory.java +++ b/single-line-diagram/single-line-diagram-core/src/main/java/com/powsybl/sld/layout/PositionVoltageLevelLayoutFactory.java @@ -49,7 +49,7 @@ public Layout create(VoltageLevelGraph graph) { positionVoltageLevelLayoutFactoryParameters.isSubstituteInternalMiddle2wtByEquipmentNodes()); // For cell detection - ImplicitCellDetector cellDetector = new ImplicitCellDetector(positionVoltageLevelLayoutFactoryParameters.isExceptionIfPatternNotHandled()); + ImplicitCellDetector cellDetector = new ImplicitCellDetector(); // For building blocks from cells BlockOrganizer blockOrganizer = new BlockOrganizer(positionFinder, positionVoltageLevelLayoutFactoryParameters.isFeederStacked(), positionVoltageLevelLayoutFactoryParameters.isExceptionIfPatternNotHandled(), positionVoltageLevelLayoutFactoryParameters.isHandleShunts(), positionVoltageLevelLayoutFactoryParameters.getBusInfoMap()); diff --git a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/raw/TestCase7CellDetectionIssue.java b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/raw/TestCase7CellDetectionIssue.java index 4f3418f93..60f3c279f 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/raw/TestCase7CellDetectionIssue.java +++ b/single-line-diagram/single-line-diagram-core/src/test/java/com/powsybl/sld/raw/TestCase7CellDetectionIssue.java @@ -39,7 +39,7 @@ public void setUp() { @Test void test() { VoltageLevelGraph g = rawGraphBuilder.buildVoltageLevelGraph("vl"); - new ImplicitCellDetector(false).detectCells(g); + new ImplicitCellDetector().detectCells(g); assertEquals(1, g.getCellStream().count()); } } diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestOneLegInternCellDifferentSubsectionsLbs.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestOneLegInternCellDifferentSubsectionsLbs.svg index 7d1c920f5..be3e12109 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestOneLegInternCellDifferentSubsectionsLbs.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestOneLegInternCellDifferentSubsectionsLbs.svg @@ -155,7 +155,7 @@ 1.1 - + 1.2 @@ -164,23 +164,23 @@ 2.1 - + - + - + - + - + diff --git a/single-line-diagram/single-line-diagram-core/src/test/resources/TestOneLegInternCellDifferentSubsectionsSi.svg b/single-line-diagram/single-line-diagram-core/src/test/resources/TestOneLegInternCellDifferentSubsectionsSi.svg index 48459dbec..fe84ad5ba 100644 --- a/single-line-diagram/single-line-diagram-core/src/test/resources/TestOneLegInternCellDifferentSubsectionsSi.svg +++ b/single-line-diagram/single-line-diagram-core/src/test/resources/TestOneLegInternCellDifferentSubsectionsSi.svg @@ -164,66 +164,66 @@ 2.1 - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - load0 + load1