From b09fccc8680aa9d156066c8c0b2a7d674ba65852 Mon Sep 17 00:00:00 2001 From: Lavender Shannon Date: Mon, 18 Mar 2024 14:04:25 -0500 Subject: [PATCH] Nicer error messages, removed rpi-cpu-temp, fixed some errorprone warnings --- .../chatbot/CancelCommandChatBotHandler.java | 3 ++- .../solarthing/chatbot/ChatBotUtil.java | 3 ++- .../chatbot/FlagCommandChatBotHandler.java | 3 ++- .../HeartbeatCommandChatBotHandler.java | 3 ++- .../ScheduleCommandChatBotHandler.java | 3 ++- .../config/request/DataRequester.java | 1 - ...aspberryPiCpuTemperatureDataRequester.java | 22 ------------------ .../solarthing/program/RoverSetupProgram.java | 7 +++--- .../solarthing/program/SolarMain.java | 1 + .../actions/mate/ACModeActionNode.java | 4 +++- .../solarthing/config/CommonConfigUtil.java | 23 ++++++++++++++++++- .../solar/common/ErrorReporter.java | 2 +- .../solar/renogy/rover/RoverReadTable.java | 2 +- .../solarthing/util/TimeUtil.java | 3 ++- .../OutbackDuplicatePacketRemoverTest.java | 2 +- 15 files changed, 45 insertions(+), 37 deletions(-) delete mode 100644 client/src/main/java/me/retrodaredevil/solarthing/config/request/RaspberryPiCpuTemperatureDataRequester.java diff --git a/client/src/main/java/me/retrodaredevil/solarthing/chatbot/CancelCommandChatBotHandler.java b/client/src/main/java/me/retrodaredevil/solarthing/chatbot/CancelCommandChatBotHandler.java index 56170942..5be65e43 100644 --- a/client/src/main/java/me/retrodaredevil/solarthing/chatbot/CancelCommandChatBotHandler.java +++ b/client/src/main/java/me/retrodaredevil/solarthing/chatbot/CancelCommandChatBotHandler.java @@ -25,6 +25,7 @@ import java.time.ZoneId; import java.util.Arrays; import java.util.List; +import java.util.Locale; import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -116,7 +117,7 @@ private void cancelCommand(MessageSender messageSender, UUID schedulingId) { @Override public boolean handleMessage(Message message, MessageSender messageSender) { - String text = message.getText().toLowerCase(); + String text = message.getText().toLowerCase(Locale.ENGLISH); String[] split = text.split(" "); if (split.length == 0) { return false; diff --git a/client/src/main/java/me/retrodaredevil/solarthing/chatbot/ChatBotUtil.java b/client/src/main/java/me/retrodaredevil/solarthing/chatbot/ChatBotUtil.java index 8ad14945..61b2d795 100644 --- a/client/src/main/java/me/retrodaredevil/solarthing/chatbot/ChatBotUtil.java +++ b/client/src/main/java/me/retrodaredevil/solarthing/chatbot/ChatBotUtil.java @@ -4,6 +4,7 @@ import me.retrodaredevil.solarthing.annotations.UtilityClass; import java.util.Iterator; +import java.util.Locale; import java.util.function.Function; @UtilityClass @@ -13,7 +14,7 @@ public final class ChatBotUtil { private static final double SIMILARITY_CONSTANT = 0.86; public static double similarity(String s1, String s2) { - return MATCHER.similarity(s1.toLowerCase(), s2.toLowerCase()); + return MATCHER.similarity(s1.toLowerCase(Locale.ENGLISH), s2.toLowerCase(Locale.ENGLISH)); } public static boolean isSimilar(String s1, String s2) { return similarity(s1, s2) > SIMILARITY_CONSTANT; diff --git a/client/src/main/java/me/retrodaredevil/solarthing/chatbot/FlagCommandChatBotHandler.java b/client/src/main/java/me/retrodaredevil/solarthing/chatbot/FlagCommandChatBotHandler.java index 675c0810..737a7387 100644 --- a/client/src/main/java/me/retrodaredevil/solarthing/chatbot/FlagCommandChatBotHandler.java +++ b/client/src/main/java/me/retrodaredevil/solarthing/chatbot/FlagCommandChatBotHandler.java @@ -36,6 +36,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Objects; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -259,7 +260,7 @@ private static Stream findAliases(Stream T readConfig(Path file, Class clazz, ObjectMapper objectMapper) { diff --git a/core/src/main/java/me/retrodaredevil/solarthing/solar/common/ErrorReporter.java b/core/src/main/java/me/retrodaredevil/solarthing/solar/common/ErrorReporter.java index 2a3a795b..122a9dd9 100644 --- a/core/src/main/java/me/retrodaredevil/solarthing/solar/common/ErrorReporter.java +++ b/core/src/main/java/me/retrodaredevil/solarthing/solar/common/ErrorReporter.java @@ -14,7 +14,7 @@ public interface ErrorReporter extends Identifiable { */ int getErrorModeValue(); @GraphQLInclude("errorModes") - @NotNull Collection<@NotNull ? extends BitmaskMode> getErrorModes(); + @NotNull Collection getErrorModes(); @GraphQLInclude("hasError") default boolean hasError() { return getErrorModeValue() != 0; diff --git a/core/src/main/java/me/retrodaredevil/solarthing/solar/renogy/rover/RoverReadTable.java b/core/src/main/java/me/retrodaredevil/solarthing/solar/renogy/rover/RoverReadTable.java index b02d5797..eeccd2b7 100644 --- a/core/src/main/java/me/retrodaredevil/solarthing/solar/renogy/rover/RoverReadTable.java +++ b/core/src/main/java/me/retrodaredevil/solarthing/solar/renogy/rover/RoverReadTable.java @@ -464,7 +464,7 @@ default int getStreetLightStatusValue(){ int getErrorModeValue(); @ValidSinceVersion(version = RoverStatusPacket.Version.CORRECT_TWO_REGISTER) @Override - default @NotNull Collection<@NotNull ? extends SimpleRoverErrorMode> getErrorModes(){ + default @NotNull Collection getErrorModes(){ if (isDcdc()) { return getDcdcErrorModes(); } diff --git a/core/src/main/java/me/retrodaredevil/solarthing/util/TimeUtil.java b/core/src/main/java/me/retrodaredevil/solarthing/util/TimeUtil.java index 8d48ac2e..2ba35cee 100644 --- a/core/src/main/java/me/retrodaredevil/solarthing/util/TimeUtil.java +++ b/core/src/main/java/me/retrodaredevil/solarthing/util/TimeUtil.java @@ -8,6 +8,7 @@ import java.time.Duration; import java.time.Instant; import java.time.format.DateTimeParseException; +import java.util.Locale; @UtilityClass public class TimeUtil { @@ -35,7 +36,7 @@ public static String millisToPrettyString(long millis) { } public static String informalDurationToFormal(String informalDuration) { - String formalDuration = informalDuration.toUpperCase() + String formalDuration = informalDuration.toUpperCase(Locale.ENGLISH) .replaceAll("SECONDS|SECOND", "S") .replaceAll("MINUTES|MINUTE", "M") .replaceAll("HOURS|HOUR", "H") diff --git a/core/src/test/java/me/retrodaredevil/solarthing/solar/outback/OutbackDuplicatePacketRemoverTest.java b/core/src/test/java/me/retrodaredevil/solarthing/solar/outback/OutbackDuplicatePacketRemoverTest.java index a06d771e..c86d54eb 100644 --- a/core/src/test/java/me/retrodaredevil/solarthing/solar/outback/OutbackDuplicatePacketRemoverTest.java +++ b/core/src/test/java/me/retrodaredevil/solarthing/solar/outback/OutbackDuplicatePacketRemoverTest.java @@ -86,7 +86,7 @@ public int getErrorModeValue() { } @Override - public @NotNull Collection<@NotNull ? extends BitmaskMode> getErrorModes() { + public @NotNull Collection getErrorModes() { throw new UnsupportedOperationException(); } };