Fix some sonar finings (2) (#1653)

Signed-off-by: Marinov Avgustin <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2024-02-19 14:45:21 +02:00
committed by GitHub
parent 92de2d573c
commit 1845f9879f
2 changed files with 12 additions and 5 deletions

View File

@@ -111,7 +111,7 @@ public class MultiDeviceApp {
public void stopOne(@ShellOption("--id") final String controllerId) {
final DdiController device = devices.get(controllerId);
if (device == null) {
System.out.println("ERROR: controller with id " + controllerId + " not found!");
throw new IllegalArgumentException("Controller with id " + controllerId + " not found!");
} else {
device.stop();
}
@@ -123,7 +123,7 @@ public class MultiDeviceApp {
@ShellOption(value = "--offset", defaultValue = "0") final int offset,
@ShellOption(value = "--count") final int count) {
for (int i = 0; i < count; i++) {
startOne(String.format(prefix + "%03d", offset + i));
startOne(toId(prefix, offset + i));
}
}
@@ -133,8 +133,12 @@ public class MultiDeviceApp {
@ShellOption(value = "--offset", defaultValue = "0") final int offset,
@ShellOption(value = "--count") final int count) {
for (int i = 0; i < count; i++) {
stopOne(String.format(prefix + "%03d", offset + i));
stopOne(toId(prefix, offset + i));
}
}
private static String toId(final String prefix, final int index) {
return String.format("%s%03d", prefix, index);
}
}
}