From 19898d2c1c6e2fb408d4d54dc49df1edf3c06aa5 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 27 May 2019 00:08:05 -0700 Subject: [PATCH] Code cleanup. --- config/pmd.xml | 3 ++- src/main/java/net/thauvin/erik/mobibot/Mobibot.java | 5 ++--- .../java/net/thauvin/erik/mobibot/entries/EntriesMgr.java | 5 +++-- .../java/net/thauvin/erik/mobibot/entries/EntryComment.java | 2 +- .../java/net/thauvin/erik/mobibot/entries/EntryLink.java | 2 +- .../net/thauvin/erik/mobibot/modules/ModuleException.java | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/config/pmd.xml b/config/pmd.xml index 547f745..6e60806 100644 --- a/config/pmd.xml +++ b/config/pmd.xml @@ -4,6 +4,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd"> Erik's Ruleset + @@ -103,7 +104,7 @@ - + diff --git a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java index 3ad36c0..c018f81 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java +++ b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java @@ -99,7 +99,7 @@ import java.util.StringTokenizer; * @since 1.0 */ @SuppressWarnings("WeakerAccess") -@Version(properties = "version.properties", template = "mobibot.mustache", className = "ReleaseInfo") +@Version(properties = "version.properties", className = "ReleaseInfo") public class Mobibot extends PircBot { // The default port. @@ -1653,10 +1653,9 @@ public class Mobibot extends PircBot { * @param isPrivate Set to true if the response should be sent as a private message. */ private void viewResponse(final String sender, final String args, final boolean isPrivate) { - String lcArgs = args.toLowerCase(Constants.LOCALE); - if (!entries.isEmpty()) { final int max = entries.size(); + String lcArgs = args.toLowerCase(Constants.LOCALE); int i = 0; if ((lcArgs.length() <= 0) && (max > MAX_ENTRIES)) { diff --git a/src/main/java/net/thauvin/erik/mobibot/entries/EntriesMgr.java b/src/main/java/net/thauvin/erik/mobibot/entries/EntriesMgr.java index fc8b401..38b9e6d 100644 --- a/src/main/java/net/thauvin/erik/mobibot/entries/EntriesMgr.java +++ b/src/main/java/net/thauvin/erik/mobibot/entries/EntriesMgr.java @@ -54,6 +54,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.Calendar; +import java.util.Collection; import java.util.List; /** @@ -99,7 +100,7 @@ public final class EntriesMgr { * @throws IOException If the file was not found or could not be read. * @throws FeedException If an error occurred while reading the feed. */ - public static void loadBacklogs(final String file, final List history) + public static void loadBacklogs(final String file, final Collection history) throws IOException, FeedException { history.clear(); @@ -131,7 +132,7 @@ public final class EntriesMgr { * @throws FeedException If an error occurred while reading the feed. */ @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops") - public static String loadEntries(final String file, final String channel, final List entries) + public static String loadEntries(final String file, final String channel, final Collection entries) throws IOException, FeedException { entries.clear(); diff --git a/src/main/java/net/thauvin/erik/mobibot/entries/EntryComment.java b/src/main/java/net/thauvin/erik/mobibot/entries/EntryComment.java index 825ed3c..1dcf4eb 100644 --- a/src/main/java/net/thauvin/erik/mobibot/entries/EntryComment.java +++ b/src/main/java/net/thauvin/erik/mobibot/entries/EntryComment.java @@ -44,7 +44,7 @@ import java.time.LocalDateTime; */ public class EntryComment implements Serializable { // The serial version UID. - static final long serialVersionUID = 6957415292233553224L; + static final long serialVersionUID = 1L; // The creation date. private final LocalDateTime date = LocalDateTime.now(); diff --git a/src/main/java/net/thauvin/erik/mobibot/entries/EntryLink.java b/src/main/java/net/thauvin/erik/mobibot/entries/EntryLink.java index f96871b..485bbd5 100644 --- a/src/main/java/net/thauvin/erik/mobibot/entries/EntryLink.java +++ b/src/main/java/net/thauvin/erik/mobibot/entries/EntryLink.java @@ -52,7 +52,7 @@ import java.util.concurrent.CopyOnWriteArrayList; */ public class EntryLink implements Serializable { // The serial version UID. - static final long serialVersionUID = 3676245542270899086L; + static final long serialVersionUID = 1L; // The link's comments private final List comments = new CopyOnWriteArrayList<>(); diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/ModuleException.java b/src/main/java/net/thauvin/erik/mobibot/modules/ModuleException.java index 4e143ef..88f5af3 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/ModuleException.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/ModuleException.java @@ -45,7 +45,7 @@ import java.util.regex.Pattern; * @since 1.0 */ public class ModuleException extends Exception { - private static final long serialVersionUID = -3036774290621088107L; + private static final long serialVersionUID = 1L; private final String debugMessage; private final Pattern urlPattern = Pattern.compile("(https?://\\S+)(\\?\\S+)");