Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Java17 syntax detection with maven-checkstyle-plugin #2659

Merged
merged 4 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void ruleChecked(RunningContext runningContext, Rule rule, RuleEvaluation
if (verbose || status == RuleEvaluationStatus.TRUE) {
out.println(" Rule '" + rule.getId() + "' evaluated to " + status);
}
if (verbose && (variables.size() + actions.size() > 0)) {
if (verbose && variables.size() + actions.size() > 0) {
Writer writer = new OutputStreamWriter(out);
try (AbstractTableFormatter formatter = new AsciiTableFormatter(writer, null,
new Column("Variable"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,19 +133,23 @@ private void applyTapChangersRegulatingControl(ThreeWindingsTransformer twt,

rtcRegulating1 = checkOnlyOneEnabled(twt.getId(), rtcRegulating1, regulatingSet, "ratioTapChanger at Leg1");
setRatioTapChangerControl(rtcRegulating1, rc.ratioTapChanger1, rtcControl1, twt.getLeg1().getRatioTapChanger());
regulatingSet = regulatingSet || (twt.getLeg1().hasRatioTapChanger() && twt.getLeg1().getRatioTapChanger().isRegulating());
regulatingSet = regulatingSet
|| twt.getLeg1().hasRatioTapChanger() && twt.getLeg1().getRatioTapChanger().isRegulating();

ptcRegulating2 = checkOnlyOneEnabled(twt.getId(), ptcRegulating2, regulatingSet, "phaseTapChanger at Leg2");
setPhaseTapChangerControl(ptcRegulating2, rc.phaseTapChanger2, ptcControl2, twt.getLeg2().getPhaseTapChanger());
regulatingSet = regulatingSet || (twt.getLeg2().hasPhaseTapChanger() && twt.getLeg2().getPhaseTapChanger().isRegulating());
regulatingSet = regulatingSet
|| twt.getLeg2().hasPhaseTapChanger() && twt.getLeg2().getPhaseTapChanger().isRegulating();

rtcRegulating2 = checkOnlyOneEnabled(twt.getId(), rtcRegulating2, regulatingSet, "ratioTapChanger at Leg2");
setRatioTapChangerControl(rtcRegulating2, rc.ratioTapChanger2, rtcControl2, twt.getLeg2().getRatioTapChanger());
regulatingSet = regulatingSet || (twt.getLeg2().hasRatioTapChanger() && twt.getLeg2().getRatioTapChanger().isRegulating());
regulatingSet = regulatingSet
|| twt.getLeg2().hasRatioTapChanger() && twt.getLeg2().getRatioTapChanger().isRegulating();

ptcRegulating3 = checkOnlyOneEnabled(twt.getId(), ptcRegulating3, regulatingSet, "phaseTapChanger at Leg3");
setPhaseTapChangerControl(ptcRegulating3, rc.phaseTapChanger3, ptcControl3, twt.getLeg3().getPhaseTapChanger());
regulatingSet = regulatingSet || (twt.getLeg3().hasPhaseTapChanger() && twt.getLeg3().getPhaseTapChanger().isRegulating());
regulatingSet = regulatingSet
|| twt.getLeg3().hasPhaseTapChanger() && twt.getLeg3().getPhaseTapChanger().isRegulating();

rtcRegulating3 = checkOnlyOneEnabled(twt.getId(), rtcRegulating3, regulatingSet, "ratioTapChanger at Leg3");
setRatioTapChangerControl(rtcRegulating3, rc.ratioTapChanger3, rtcControl3, twt.getLeg3().getRatioTapChanger());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ public SvInjectionConversion(PropertyBag p, Context context) {
@Override
public boolean valid() {
return voltageLevel != null
&& ((context.nodeBreaker() && node != -1)
|| (!context.nodeBreaker() && voltageLevel.getBusBreakerView().getBus(busId) != null));
&& (context.nodeBreaker() && node != -1
|| !context.nodeBreaker() && voltageLevel.getBusBreakerView().getBus(busId) != null);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ private static void writeGeneratingUnitsParticitationFactors(Network network, St
}

private static GeneratingUnit generatingUnitForGeneratorAndBatteries(Injection<?> i, CgmesExportContext context) {
if (i.hasProperty(GENERATING_UNIT_PROPERTY) && ((i.getExtension(ActivePowerControl.class) != null) || i.hasProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + "normalPF"))) {
if (i.hasProperty(GENERATING_UNIT_PROPERTY) && (i.getExtension(ActivePowerControl.class) != null || i.hasProperty(Conversion.CGMES_PREFIX_ALIAS_PROPERTIES + "normalPF"))) {
GeneratingUnit gu = new GeneratingUnit();
gu.id = context.getNamingStrategy().getCgmesIdFromProperty(i, GENERATING_UNIT_PROPERTY);
if (i.getExtension(ActivePowerControl.class) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ static boolean isConsideredForNetwork(Attr attr) {
}
if (attr.getLocalName().equals("value")) {
Element e = attr.getOwnerElement();
return !e.getLocalName().equals("property") ||
(!"CGMES.TP_ID".equals(e.getAttribute("name")) && !"CGMES.SSH_ID".equals(e.getAttribute("name")));
return !e.getLocalName().equals("property")
|| !"CGMES.TP_ID".equals(e.getAttribute("name")) && !"CGMES.SSH_ID".equals(e.getAttribute("name"));
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ public boolean isValidName(String contextName) {
EQUIPMENT_BOUNDARY("EQ_BD") {
@Override
public boolean isValidName(String contextName) {
return super.isValidName(contextName) || (EQUIPMENT.isValidName(contextName) && isBoundary(contextName));
return super.isValidName(contextName)
|| EQUIPMENT.isValidName(contextName) && isBoundary(contextName);
}
},
TOPOLOGY_BOUNDARY("TP_BD") {
@Override
public boolean isValidName(String contextName) {
return super.isValidName(contextName) || (TOPOLOGY.isValidName(contextName) && isBoundary(contextName));
return super.isValidName(contextName)
|| TOPOLOGY.isValidName(contextName) && isBoundary(contextName);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public T getExtendable() {
}

public void setExtendable(T extendable) {
if ((extendable != null) && (this.extendable != null) && (this.extendable != extendable)) {
if (extendable != null && this.extendable != null && this.extendable != extendable) {
throw new PowsyblException("Extension is already associated to the extendable " + this.extendable);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ void testUnauthorizedColspan() throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try (Writer writer = new OutputStreamWriter(bos, StandardCharsets.UTF_8);
AsciiTableFormatter formatter = new AsciiTableFormatter(writer, null, config,
new Column("column1").setColspan(4).setHorizontalAlignment(HorizontalAlignment.CENTER),
new Column("column2").setColspan(2).setHorizontalAlignment(HorizontalAlignment.CENTER))) {
new Column("column1").setColspan(4).setHorizontalAlignment(HorizontalAlignment.CENTER),
new Column("column2").setColspan(2).setHorizontalAlignment(HorizontalAlignment.CENTER))) {
IllegalArgumentException e = assertThrows(IllegalArgumentException.class, () -> formatter.writeCell("Line:1 Cell:1", 1)
.writeCell("Line:1 Cell:2", 1)
.writeCell("Line:1 Cell:3", 1)
Expand All @@ -91,8 +91,8 @@ void testEmptyLines() throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try (Writer writer = new OutputStreamWriter(bos, StandardCharsets.UTF_8);
AsciiTableFormatter formatter = new AsciiTableFormatter(writer, null, config,
new Column("column1").setColspan(4),
new Column("column2").setColspan(2))) {
new Column("column1").setColspan(4),
new Column("column2").setColspan(2))) {
formatter.writeCell("Line:1 Cell:1")
.writeCell("Line:1 Cell:2")
.writeCell("Line:1 Cell:3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,10 @@ private static boolean checkShuntCompensatorContingency(Contingency contingency,

private static boolean checkBranchContingency(Contingency contingency, BranchContingency element, Network network) {
Branch branch = network.getBranch(element.getId());
if (branch == null || (element.getVoltageLevelId() != null &&
!(element.getVoltageLevelId().equals(branch.getTerminal1().getVoltageLevel().getId()) ||
element.getVoltageLevelId().equals(branch.getTerminal2().getVoltageLevel().getId())))) {
if (branch == null
|| element.getVoltageLevelId() != null
&& !(element.getVoltageLevelId().equals(branch.getTerminal1().getVoltageLevel().getId())
|| element.getVoltageLevelId().equals(branch.getTerminal2().getVoltageLevel().getId()))) {
LOGGER.warn("Branch '{}' of contingency '{}' not found", element.getId(), contingency.getId());
return false;
}
Expand All @@ -188,9 +189,10 @@ private static boolean checkBranchContingency(Contingency contingency, BranchCon

private static boolean checkLineContingency(Contingency contingency, LineContingency element, Network network) {
Line line = network.getLine(element.getId());
if (line == null || (element.getVoltageLevelId() != null &&
!(element.getVoltageLevelId().equals(line.getTerminal1().getVoltageLevel().getId()) ||
element.getVoltageLevelId().equals(line.getTerminal2().getVoltageLevel().getId())))) {
if (line == null
|| element.getVoltageLevelId() != null
&& !(element.getVoltageLevelId().equals(line.getTerminal1().getVoltageLevel().getId())
|| element.getVoltageLevelId().equals(line.getTerminal2().getVoltageLevel().getId()))) {
LOGGER.warn("Line '{}' of contingency '{}' not found", element.getId(), contingency.getId());
return false;
}
Expand All @@ -199,9 +201,10 @@ private static boolean checkLineContingency(Contingency contingency, LineConting

private static boolean checkTwoWindingsTransformerContingency(Contingency contingency, TwoWindingsTransformerContingency element, Network network) {
TwoWindingsTransformer twt = network.getTwoWindingsTransformer(element.getId());
if (twt == null || (element.getVoltageLevelId() != null &&
!(element.getVoltageLevelId().equals(twt.getTerminal1().getVoltageLevel().getId()) ||
element.getVoltageLevelId().equals(twt.getTerminal2().getVoltageLevel().getId())))) {
if (twt == null
|| element.getVoltageLevelId() != null
&& !(element.getVoltageLevelId().equals(twt.getTerminal1().getVoltageLevel().getId())
|| element.getVoltageLevelId().equals(twt.getTerminal2().getVoltageLevel().getId()))) {
LOGGER.warn("TwoWindingsTransformer '{}' of contingency '{}' not found", element.getId(), contingency.getId());
return false;
}
Expand All @@ -210,9 +213,10 @@ private static boolean checkTwoWindingsTransformerContingency(Contingency contin

private static boolean checkHvdcLineContingency(Contingency contingency, HvdcLineContingency element, Network network) {
HvdcLine hvdcLine = network.getHvdcLine(element.getId());
if (hvdcLine == null || (element.getVoltageLevelId() != null &&
!(element.getVoltageLevelId().equals(hvdcLine.getConverterStation1().getTerminal().getVoltageLevel().getId()) ||
element.getVoltageLevelId().equals(hvdcLine.getConverterStation2().getTerminal().getVoltageLevel().getId())))) {
if (hvdcLine == null
|| element.getVoltageLevelId() != null
&& !(element.getVoltageLevelId().equals(hvdcLine.getConverterStation1().getTerminal().getVoltageLevel().getId())
|| element.getVoltageLevelId().equals(hvdcLine.getConverterStation2().getTerminal().getVoltageLevel().getId()))) {
LOGGER.warn("HVDC line '{}' of contingency '{}' not found", element.getId(), contingency.getId());
return false;
}
Expand Down Expand Up @@ -261,9 +265,10 @@ private static boolean checkBusContingency(Contingency contingency, BusContingen

private static boolean checkTieLineContingency(Contingency contingency, TieLineContingency element, Network network) {
TieLine tieLine = network.getTieLine(element.getId());
if (tieLine == null || (element.getVoltageLevelId() != null &&
!(element.getVoltageLevelId().equals(tieLine.getDanglingLine1().getTerminal().getVoltageLevel().getId()) ||
element.getVoltageLevelId().equals(tieLine.getDanglingLine2().getTerminal().getVoltageLevel().getId())))) {
if (tieLine == null
|| element.getVoltageLevelId() != null
&& !(element.getVoltageLevelId().equals(tieLine.getDanglingLine1().getTerminal().getVoltageLevel().getId())
|| element.getVoltageLevelId().equals(tieLine.getDanglingLine2().getTerminal().getVoltageLevel().getId()))) {
LOGGER.warn("Tie line '{}' of contingency '{}' not found", element.getId(), contingency.getId());
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ private boolean filterThreeWindingsTransformer(ThreeWindingsTransformer threeWin
return filterSubstationOrVoltageLevel(voltageLevel1) || filterSubstationOrVoltageLevel(voltageLevel2) ||
filterSubstationOrVoltageLevel(voltageLevel3);
case BOTH:
return (filterSubstationOrVoltageLevel(voltageLevel1) && filterSubstationOrVoltageLevel(voltageLevel2)) ||
(filterSubstationOrVoltageLevel(voltageLevel1) && filterSubstationOrVoltageLevel(voltageLevel3)) ||
(filterSubstationOrVoltageLevel(voltageLevel2) && filterSubstationOrVoltageLevel(voltageLevel3));
return filterSubstationOrVoltageLevel(voltageLevel1) && filterSubstationOrVoltageLevel(voltageLevel2)
|| filterSubstationOrVoltageLevel(voltageLevel1) && filterSubstationOrVoltageLevel(voltageLevel3)
|| filterSubstationOrVoltageLevel(voltageLevel2) && filterSubstationOrVoltageLevel(voltageLevel3);
case ALL_THREE:
return filterSubstationOrVoltageLevel(voltageLevel1) && filterSubstationOrVoltageLevel(voltageLevel2) &&
filterSubstationOrVoltageLevel(voltageLevel3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ private boolean filterBranch(Terminal terminal1, Terminal terminal2) {
if (countrySide1 == null && !countries1.isEmpty() || countrySide2 == null && !countries2.isEmpty()) {
return false;
}
return (countries1.isEmpty() && countries2.isEmpty()) ||
(countries1.isEmpty() && (countries2.contains(countrySide2) || countries2.contains(countrySide1))) ||
(countries2.isEmpty() && (countries1.contains(countrySide2) || countries1.contains(countrySide1))) ||
(countries1.contains(countrySide1) && countries2.contains(countrySide2)) ||
(countries1.contains(countrySide2) && countries2.contains(countrySide1));
return countries1.isEmpty() && countries2.isEmpty()
|| countries1.isEmpty() && (countries2.contains(countrySide2) || countries2.contains(countrySide1))
|| countries2.isEmpty() && (countries1.contains(countrySide2) || countries1.contains(countrySide1))
|| countries1.contains(countrySide1) && countries2.contains(countrySide2)
|| countries1.contains(countrySide2) && countries2.contains(countrySide1);
}

public List<Country> getCountries1() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public static double getSign(HvdcConverterStation<?> station) {
public static boolean isRectifier(HvdcConverterStation<?> station) {
Objects.requireNonNull(station);
HvdcLine line = station.getHvdcLine();
return (line.getConverterStation1() == station && line.getConvertersMode() == HvdcLine.ConvertersMode.SIDE_1_RECTIFIER_SIDE_2_INVERTER)
|| (line.getConverterStation2() == station && line.getConvertersMode() == HvdcLine.ConvertersMode.SIDE_1_INVERTER_SIDE_2_RECTIFIER);
return line.getConverterStation1() == station && line.getConvertersMode() == HvdcLine.ConvertersMode.SIDE_1_RECTIFIER_SIDE_2_INVERTER
|| line.getConverterStation2() == station && line.getConvertersMode() == HvdcLine.ConvertersMode.SIDE_1_INVERTER_SIDE_2_RECTIFIER;
}

private static double getAbsoluteValuePAc(HvdcConverterStation<?> station) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static boolean checkPermanentLimit(Branch<?> branch, Branch.Side side, fl
return branch.getLimits(type, side)
.map(l -> !Double.isNaN(l.getPermanentLimit()) &&
!Double.isNaN(i) &&
(i >= l.getPermanentLimit() * limitReduction))
i >= l.getPermanentLimit() * limitReduction)
.orElse(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,10 @@ public static void findAndAssociateDanglingLines(DanglingLine candidateDanglingL
}
} else {
// if dangling line with same ID present, there is only one: they are associated if the X-node code is identical (if not: throw exception)
if ((danglingLine.getUcteXnodeCode() != null && candidateDanglingLine.getUcteXnodeCode() != null
&& !danglingLine.getUcteXnodeCode().equals(candidateDanglingLine.getUcteXnodeCode())) || (danglingLine.getUcteXnodeCode() == null && candidateDanglingLine.getUcteXnodeCode() == null)) {
boolean nonNullAndDifferent = danglingLine.getUcteXnodeCode() != null && candidateDanglingLine.getUcteXnodeCode() != null
&& !danglingLine.getUcteXnodeCode().equals(candidateDanglingLine.getUcteXnodeCode());
boolean bothNull = danglingLine.getUcteXnodeCode() == null && candidateDanglingLine.getUcteXnodeCode() == null;
if (nonNullAndDifferent || bothNull) {
throw new PowsyblException("Dangling line couple " + danglingLine.getId()
+ " have inconsistent Xnodes (" + danglingLine.getUcteXnodeCode()
+ "!=" + candidateDanglingLine.getUcteXnodeCode() + ")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ public boolean isValid(UndirectedGraph<? extends TerminalExt, SwitchImpl> graph,
}
}
}
return (busbarSectionCount >= 1 && feederCount >= 1)
|| (branchCount >= 1 && feederCount >= 2);
return busbarSectionCount >= 1 && feederCount >= 1
|| branchCount >= 1 && feederCount >= 2;
}
}

Expand Down Expand Up @@ -822,8 +822,8 @@ public int getNode2() {
public void removeInternalConnections(int node1, int node2) {
int[] internalConnectionsToBeRemoved = Arrays.stream(graph.getEdges())
.filter(e -> graph.getEdgeObject(e) == null)
.filter(e -> (graph.getEdgeVertex1(e) == node1 && graph.getEdgeVertex2(e) == node2) ||
(graph.getEdgeVertex1(e) == node2 && graph.getEdgeVertex2(e) == node1))
.filter(e -> graph.getEdgeVertex1(e) == node1 && graph.getEdgeVertex2(e) == node2
|| graph.getEdgeVertex1(e) == node2 && graph.getEdgeVertex2(e) == node1)
.toArray();
if (internalConnectionsToBeRemoved.length == 0) {
throw new PowsyblException("Internal connection not found between " + node1 + " and " + node2);
Expand Down
Loading