From 6d3e3f2c6ea1568a6400e1fc4e15a9f5c14e76d9 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Mon, 1 Apr 2019 21:59:23 -0700 Subject: [PATCH] sonarcloud code improvements. --- sonar-project.properties | 2 + .../net/thauvin/erik/mobibot/Commands.java | 5 +- .../net/thauvin/erik/mobibot/EntriesMgr.java | 171 ++++++++---------- .../thauvin/erik/mobibot/EntryComment.java | 2 +- .../net/thauvin/erik/mobibot/EntryLink.java | 10 +- .../net/thauvin/erik/mobibot/Mobibot.java | 42 ++--- .../java/net/thauvin/erik/mobibot/Tell.java | 15 +- .../net/thauvin/erik/mobibot/TellMessage.java | 4 +- .../thauvin/erik/mobibot/TellMessagesMgr.java | 5 +- .../java/net/thauvin/erik/mobibot/Utils.java | 5 +- .../thauvin/erik/mobibot/modules/Calc.java | 2 +- .../mobibot/modules/CurrencyConverter.java | 4 +- .../thauvin/erik/mobibot/modules/Dice.java | 2 +- .../erik/mobibot/modules/GoogleSearch.java | 2 +- .../thauvin/erik/mobibot/modules/Joke.java | 2 +- .../thauvin/erik/mobibot/modules/Lookup.java | 2 +- .../erik/mobibot/modules/StockQuote.java | 2 +- .../thauvin/erik/mobibot/modules/Twitter.java | 12 +- .../net/thauvin/erik/mobibot/modules/War.java | 4 +- .../erik/mobibot/modules/WorldTime.java | 2 +- 20 files changed, 139 insertions(+), 156 deletions(-) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..27314ec --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,2 @@ +sonar.projectKey=ethauvin_semver +sonar.sourceEncoding=UTF-8 diff --git a/src/main/java/net/thauvin/erik/mobibot/Commands.java b/src/main/java/net/thauvin/erik/mobibot/Commands.java index c5eef7b..14b642c 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Commands.java +++ b/src/main/java/net/thauvin/erik/mobibot/Commands.java @@ -38,7 +38,7 @@ package net.thauvin.erik.mobibot; * @created 2014-04-26 * @since 1.0 */ -final public class Commands { +public final class Commands { /** * The add (back)log command. */ @@ -159,8 +159,7 @@ final public class Commands { * * @throws UnsupportedOperationException If the constructor is called. */ - private Commands() - throws UnsupportedOperationException { + private Commands() { throw new UnsupportedOperationException("Illegal constructor call."); } } diff --git a/src/main/java/net/thauvin/erik/mobibot/EntriesMgr.java b/src/main/java/net/thauvin/erik/mobibot/EntriesMgr.java index 839d0c1..3fa4ddb 100644 --- a/src/main/java/net/thauvin/erik/mobibot/EntriesMgr.java +++ b/src/main/java/net/thauvin/erik/mobibot/EntriesMgr.java @@ -73,8 +73,7 @@ final class EntriesMgr { * * @throws UnsupportedOperationException If the constructor is called. */ - private EntriesMgr() - throws UnsupportedOperationException { + private EntriesMgr() { throw new UnsupportedOperationException("Illegal constructor call."); } @@ -184,78 +183,76 @@ final class EntriesMgr { } if (Utils.isValidString(bot.getLogsDir()) && Utils.isValidString(bot.getWeblogUrl())) { - Writer fw = null; - try { - fw = new OutputStreamWriter( - new FileOutputStream(bot.getLogsDir() + CURRENT_XML), StandardCharsets.UTF_8); - + final SyndFeedOutput output = new SyndFeedOutput(); SyndFeed rss = new SyndFeedImpl(); - rss.setFeedType("rss_2.0"); - rss.setTitle(bot.getChannel() + " IRC Links"); - rss.setDescription("Links from " + bot.getIrcServer() + " on " + bot.getChannel()); - rss.setLink(bot.getWeblogUrl()); - rss.setPublishedDate(Calendar.getInstance().getTime()); - rss.setLanguage("en"); - - EntryLink entry; - StringBuffer buff; - EntryComment comment; final List items = new ArrayList<>(0); SyndEntry item; SyndContent description; + try (final Writer fw = new OutputStreamWriter( + new FileOutputStream(bot.getLogsDir() + CURRENT_XML), StandardCharsets.UTF_8)) { + rss.setFeedType("rss_2.0"); + rss.setTitle(bot.getChannel() + " IRC Links"); + rss.setDescription("Links from " + bot.getIrcServer() + " on " + bot.getChannel()); + rss.setLink(bot.getWeblogUrl()); + rss.setPublishedDate(Calendar.getInstance().getTime()); + rss.setLanguage("en"); - for (int i = (entries.size() - 1); i >= 0; --i) { - entry = entries.get(i); + EntryLink entry; + StringBuilder buff; + EntryComment comment; - buff = new StringBuffer( - "Posted by " + entry.getNick() + " on " + entry.getChannel() + ""); + for (int i = (entries.size() - 1); i >= 0; --i) { + entry = entries.get(i); - if (entry.getCommentsCount() > 0) { - buff.append("

"); + buff = new StringBuilder( + "Posted by " + entry.getNick() + " on " + entry.getChannel() + ""); - final EntryComment[] comments = entry.getComments(); + if (entry.getCommentsCount() > 0) { + buff.append("

"); - for (int j = 0; j < comments.length; j++) { - comment = comments[j]; + final EntryComment[] comments = entry.getComments(); - if (j > 0) { - buff.append("
"); + for (int j = 0; j < comments.length; j++) { + comment = comments[j]; + + if (j > 0) { + buff.append("
"); + } + + buff.append(comment.getNick()).append(": ").append(comment.getComment()); } - - buff.append(comment.getNick()).append(": ").append(comment.getComment()); } + + item = new SyndEntryImpl(); + item.setLink(entry.getLink()); + description = new SyndContentImpl(); + description.setValue(buff.toString()); + item.setDescription(description); + item.setTitle(entry.getTitle()); + item.setPublishedDate(entry.getDate()); + item.setAuthor( + bot.getChannel().substring(1) + '@' + bot.getIrcServer() + " (" + entry.getNick() + ')'); + item.setCategories(entry.getTags()); + + items.add(item); } - item = new SyndEntryImpl(); - item.setLink(entry.getLink()); - description = new SyndContentImpl(); - description.setValue(buff.toString()); - item.setDescription(description); - item.setTitle(entry.getTitle()); - item.setPublishedDate(entry.getDate()); - item.setAuthor( - bot.getChannel().substring(1) + '@' + bot.getIrcServer() + " (" + entry.getNick() + ')'); - item.setCategories(entry.getTags()); + rss.setEntries(items); - items.add(item); + if (bot.getLogger().isDebugEnabled()) { + bot.getLogger().debug("Writing the entries feed."); + } + + output.output(rss, fw); } - rss.setEntries(items); - - if (bot.getLogger().isDebugEnabled()) { - bot.getLogger().debug("Writing the entries feed."); - } - - final SyndFeedOutput output = new SyndFeedOutput(); - output.output(rss, fw); - fw.close(); - - fw = new OutputStreamWriter( + try (final Writer fw = new OutputStreamWriter( new FileOutputStream( - bot.getLogsDir() + bot.getToday() + XML_EXT), StandardCharsets.UTF_8); - output.output(rss, fw); + bot.getLogsDir() + bot.getToday() + XML_EXT), StandardCharsets.UTF_8)) { + output.output(rss, fw); + } if (isDayBackup) { if (Utils.isValidString(bot.getBacklogsUrl())) { @@ -266,54 +263,46 @@ final class EntriesMgr { history.remove(0); } } + + try (final Writer fw = new OutputStreamWriter( + new FileOutputStream(bot.getLogsDir() + NAV_XML), StandardCharsets.UTF_8)) { + rss = new SyndFeedImpl(); + rss.setFeedType("rss_2.0"); + rss.setTitle(bot.getChannel() + " IRC Links Backlogs"); + rss.setDescription("Backlogs of Links from " + bot.getIrcServer() + " on " + bot.getChannel()); + rss.setLink(bot.getBacklogsUrl()); + rss.setPublishedDate(Calendar.getInstance().getTime()); - fw.close(); - fw = new OutputStreamWriter( - new FileOutputStream(bot.getLogsDir() + NAV_XML), StandardCharsets.UTF_8); - rss = new SyndFeedImpl(); - rss.setFeedType("rss_2.0"); - rss.setTitle(bot.getChannel() + " IRC Links Backlogs"); - rss.setDescription("Backlogs of Links from " + bot.getIrcServer() + " on " + bot.getChannel()); - rss.setLink(bot.getBacklogsUrl()); - rss.setPublishedDate(Calendar.getInstance().getTime()); + String date; + items.clear(); - String date; - items.clear(); + for (int i = (history.size() - 1); i >= 0; --i) { + date = history.get(i); - for (int i = (history.size() - 1); i >= 0; --i) { - date = history.get(i); + item = new SyndEntryImpl(); + item.setLink(bot.getBacklogsUrl() + date + ".xml"); + item.setTitle(date); + description = new SyndContentImpl(); + description.setValue("Links for " + date); + item.setDescription(description); - item = new SyndEntryImpl(); - item.setLink(bot.getBacklogsUrl() + date + ".xml"); - item.setTitle(date); - description = new SyndContentImpl(); - description.setValue("Links for " + date); - item.setDescription(description); + items.add(item); + } - items.add(item); + rss.setEntries(items); + + if (bot.getLogger().isDebugEnabled()) { + bot.getLogger().debug("Writing the backlog feed."); + } + + output.output(rss, fw); } - - rss.setEntries(items); - - if (bot.getLogger().isDebugEnabled()) { - bot.getLogger().debug("Writing the backlog feed."); - } - - output.output(rss, fw); } else { bot.getLogger().warn("Unable to generate the backlogs feed. No property configured."); } } } catch (FeedException | IOException e) { bot.getLogger().warn("Unable to generate the entries feed.", e); - } finally { - try { - if (fw != null) { - fw.close(); - } - } catch (Exception ignore) { - ; // Do nothing - } } } else { bot.getLogger() diff --git a/src/main/java/net/thauvin/erik/mobibot/EntryComment.java b/src/main/java/net/thauvin/erik/mobibot/EntryComment.java index 32ec725..a148068 100644 --- a/src/main/java/net/thauvin/erik/mobibot/EntryComment.java +++ b/src/main/java/net/thauvin/erik/mobibot/EntryComment.java @@ -67,7 +67,7 @@ public class EntryComment implements Serializable { */ @SuppressWarnings("UnusedDeclaration") protected EntryComment() { - ; // Required for serialization. + // Required for serialization. } /** diff --git a/src/main/java/net/thauvin/erik/mobibot/EntryLink.java b/src/main/java/net/thauvin/erik/mobibot/EntryLink.java index ab2ecc9..114248d 100644 --- a/src/main/java/net/thauvin/erik/mobibot/EntryLink.java +++ b/src/main/java/net/thauvin/erik/mobibot/EntryLink.java @@ -266,14 +266,14 @@ public class EntryLink implements Serializable { * @return The tags as a comma-delimited string. */ public final String getPinboardTags() { - final StringBuilder tags = new StringBuilder(nick); + final StringBuilder pinboardTags = new StringBuilder(nick); - for (final Object tag : this.tags) { - tags.append(','); - tags.append(((SyndCategoryImpl) tag).getName()); + for (final SyndCategory tag : tags) { + pinboardTags.append(','); + pinboardTags.append(tag.getName()); } - return tags.toString(); + return pinboardTags.toString(); } /** diff --git a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java index 1ba630d..56bc199 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Mobibot.java +++ b/src/main/java/net/thauvin/erik/mobibot/Mobibot.java @@ -57,6 +57,7 @@ import java.util.*; * @created Jan 31, 2004 * @since 1.0 */ +@SuppressWarnings("WeakerAccess") @Version(properties = "version.properties", className = "ReleaseInfo") public class Mobibot extends PircBot { /** @@ -182,7 +183,6 @@ public class Mobibot extends PircBot { * @param logsDirPath The path to the logs directory. * @param p The bot's properties. */ - @SuppressWarnings("WeakerAccess") public Mobibot(final String nickname, final String channel, final String logsDirPath, final Properties p) { System.getProperties().setProperty("sun.net.client.defaultConnectTimeout", String.valueOf(CONNECT_TIMEOUT)); System.getProperties().setProperty("sun.net.client.defaultReadTimeout", String.valueOf(CONNECT_TIMEOUT)); @@ -210,7 +210,7 @@ public class Mobibot extends PircBot { today = Utils.today(); } } catch (IOException ignore) { - ; // Do nothing. + // Do nothing. } catch (FeedException e) { logger.error("An error occurred while parsing the '" + EntriesMgr.CURRENT_XML + "' file.", e); } @@ -219,7 +219,7 @@ public class Mobibot extends PircBot { try { EntriesMgr.loadBacklogs(logsDir + EntriesMgr.NAV_XML, history); } catch (IOException ignore) { - ; // Do nothing. + // Do nothing. } catch (FeedException e) { logger.error("An error occurred while parsing the '" + EntriesMgr.NAV_XML + "' file.", e); } @@ -335,30 +335,24 @@ public class Mobibot extends PircBot { // Redirect the stdout and stderr if (!line.hasOption(Commands.DEBUG_ARG.charAt(0))) { - PrintStream stdout = null; - - try { - stdout = new PrintStream(new FileOutputStream( - logsDir + channel.substring(1) + '.' + Utils.today() + ".log", true)); + try (final PrintStream stdout = new PrintStream(new FileOutputStream( + logsDir + channel.substring(1) + '.' + Utils.today() + ".log", true))) { + System.setOut(stdout); } catch (IOException e) { System.err.println("Unable to open output (stdout) log file."); e.printStackTrace(System.err); System.exit(1); } - PrintStream stderr = null; - try { - stderr = new PrintStream( - new FileOutputStream(logsDir + nickname + ".err", true)); + try (final PrintStream stderr = new PrintStream( + new FileOutputStream(logsDir + nickname + ".err", true))) { + System.setErr(stderr); } catch (IOException e) { System.err.println("Unable to open error (stderr) log file."); e.printStackTrace(System.err); System.exit(1); } - - System.setOut(stdout); - System.setErr(stderr); } // Create the bot @@ -378,7 +372,7 @@ public class Mobibot extends PircBot { try { Thread.sleep((long) (secs * 1000)); } catch (InterruptedException ignore) { - ; // Do nothing + // Do nothing. } } @@ -387,7 +381,7 @@ public class Mobibot extends PircBot { * * @param action The action. */ - final public void action(final String action) { + public final void action(final String action) { action(ircChannel, action); } @@ -580,7 +574,7 @@ public class Mobibot extends PircBot { * @param help The help string. * @return The indented help string. */ - final public String helpIndent(final String help) { + public final String helpIndent(final String help) { return helpIndent(help, true); } @@ -624,7 +618,7 @@ public class Mobibot extends PircBot { } else if (lcTopic.equals(Commands.VIEW_CMD)) { send(sender, "To list or search the current URL posts:"); send(sender, helpIndent(getNick() + ": " + Commands.VIEW_CMD) + " [] []"); - } else if (lcTopic.equals(ircChannel.substring(1).toLowerCase())) { + } else if (lcTopic.equalsIgnoreCase(ircChannel.substring(1))) { send(sender, "To list the last 5 posts from the channel's weblog:"); send(sender, helpIndent(getNick() + ": " + ircChannel.substring(1))); } else if (lcTopic.equals(Commands.RECAP_CMD)) { @@ -1390,9 +1384,9 @@ public class Mobibot extends PircBot { * @param isPrivate Set to true if the response should be sent as a private message. */ private void recapResponse(final String sender, final boolean isPrivate) { - if (recap.size() > 0) { - for (final String recap : recap) { - send(sender, recap, isPrivate); + if (recap.isEmpty()) { + for (final String r : recap) { + send(sender, r, isPrivate); } } else { send(sender, "Sorry, nothing to recap.", true); @@ -1574,7 +1568,7 @@ public class Mobibot extends PircBot { final int max = entries.size(); int i = 0; - if (!(lcArgs.length() > 0) && (max > MAX_ENTRIES)) { + if ((lcArgs.length() <= 0) && (max > MAX_ENTRIES)) { i = max - MAX_ENTRIES; } @@ -1598,7 +1592,7 @@ public class Mobibot extends PircBot { i = 0; } } catch (NumberFormatException ignore) { - ; // Do nothing + // Do nothing. } } diff --git a/src/main/java/net/thauvin/erik/mobibot/Tell.java b/src/main/java/net/thauvin/erik/mobibot/Tell.java index 89f6a4e..d330622 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Tell.java +++ b/src/main/java/net/thauvin/erik/mobibot/Tell.java @@ -67,13 +67,13 @@ public class Tell { private static final String SER_EXT = ".ser"; // The bot instance. - final private Mobibot bot; + private final Mobibot bot; // The maximum number of days to keep messages. - final private int maxDays; + private final int maxDays; // The message maximum queue size. - final private int maxSize; + private final int maxSize; // The messages queue. private final List messages = new CopyOnWriteArrayList<>(); @@ -139,13 +139,14 @@ public class Tell { * @param cmds The commands string. */ public void response(final String sender, final String cmds) { + final String arrow = " --> "; if (!Utils.isValidString(cmds)) { helpResponse(sender); } else if (cmds.startsWith(Commands.VIEW_CMD)) { if (bot.isOp(sender) && cmds.equals(Commands.VIEW_CMD + ' ' + TELL_ALL_KEYWORD)) { - if (messages.size() > 0) { + if (messages.isEmpty()) { for (final TellMessage message : messages) { - bot.send(sender, Utils.bold(message.getSender()) + " --> " + Utils.bold(message.getRecipient()) + bot.send(sender, Utils.bold(message.getSender()) + arrow + Utils.bold(message.getRecipient()) + " [ID: " + message.getId() + ", " + (message.isReceived() ? "DELIVERED" : "QUEUED") + ']', true); @@ -165,14 +166,14 @@ public class Tell { if (message.isReceived()) { bot.send(sender, - Utils.bold(message.getSender()) + " --> " + Utils.bold(message.getRecipient()) + Utils.bold(message.getSender()) + arrow + Utils.bold(message.getRecipient()) + " [" + Utils.utcDateTime(message.getReceived()) + ", ID: " + message.getId() + ", DELIVERED]", true); } else { bot.send(sender, - Utils.bold(message.getSender()) + " --> " + Utils.bold(message.getRecipient()) + Utils.bold(message.getSender()) + arrow + Utils.bold(message.getRecipient()) + " [" + Utils.utcDateTime(message.getQueued()) + ", ID: " + message.getId() + ", QUEUED]", true); diff --git a/src/main/java/net/thauvin/erik/mobibot/TellMessage.java b/src/main/java/net/thauvin/erik/mobibot/TellMessage.java index 3318c19..1412206 100644 --- a/src/main/java/net/thauvin/erik/mobibot/TellMessage.java +++ b/src/main/java/net/thauvin/erik/mobibot/TellMessage.java @@ -47,7 +47,7 @@ public class TellMessage implements Serializable { private static final long serialVersionUID = 2L; private final String id; private final String message; - final private LocalDateTime queued; + private final LocalDateTime queued; private final String recipient; private final String sender; private boolean isNotified; @@ -176,4 +176,4 @@ public class TellMessage implements Serializable { received = LocalDateTime.now(Clock.systemUTC()); isReceived = true; } -} \ No newline at end of file +} diff --git a/src/main/java/net/thauvin/erik/mobibot/TellMessagesMgr.java b/src/main/java/net/thauvin/erik/mobibot/TellMessagesMgr.java index 1397986..2b84b02 100644 --- a/src/main/java/net/thauvin/erik/mobibot/TellMessagesMgr.java +++ b/src/main/java/net/thauvin/erik/mobibot/TellMessagesMgr.java @@ -52,8 +52,7 @@ final class TellMessagesMgr { * * @throws UnsupportedOperationException If the constructor is called. */ - private TellMessagesMgr() - throws UnsupportedOperationException { + private TellMessagesMgr() { throw new UnsupportedOperationException("Illegal constructor call."); } @@ -98,7 +97,7 @@ final class TellMessagesMgr { return ((List) input.readObject()); } } catch (FileNotFoundException ignore) { - ; // Do nothing. + // Do nothing. } catch (IOException e) { logger.error("An IO error occurred loading the messages queue.", e); } catch (Exception e) { diff --git a/src/main/java/net/thauvin/erik/mobibot/Utils.java b/src/main/java/net/thauvin/erik/mobibot/Utils.java index ef9d181..1033a4d 100644 --- a/src/main/java/net/thauvin/erik/mobibot/Utils.java +++ b/src/main/java/net/thauvin/erik/mobibot/Utils.java @@ -46,14 +46,13 @@ import java.util.Date; * @created 2014-04-26 * @since 1.0 */ -final public class Utils { +public final class Utils { /** * Disables the default constructor. * * @throws UnsupportedOperationException If the constructor is called. */ - private Utils() - throws UnsupportedOperationException { + private Utils() { throw new UnsupportedOperationException("Illegal constructor call."); } diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Calc.java b/src/main/java/net/thauvin/erik/mobibot/modules/Calc.java index 677dd5b..1306373 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/Calc.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/Calc.java @@ -90,4 +90,4 @@ public class Calc extends AbstractModule { bot.send(sender, "To solve a mathematical calculation:"); bot.send(sender, bot.helpIndent(bot.getNick() + ": " + CALC_CMD + " ")); } -} \ No newline at end of file +} diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.java b/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.java index 57a33cf..3498a87 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.java @@ -55,7 +55,7 @@ import java.util.TreeMap; * @created Feb 11, 2004 * @since 1.0 */ -final public class CurrencyConverter extends AbstractModule { +public final class CurrencyConverter extends AbstractModule { /** * The currency command. */ @@ -73,7 +73,7 @@ final public class CurrencyConverter extends AbstractModule { private static final String EXCHANGE_TABLE_URL = "http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml"; // The last exchange rates table publication date. - private static String pubDate = ""; + private String pubDate = ""; /** * Creates a new {@link CurrencyConverter} instance. diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Dice.java b/src/main/java/net/thauvin/erik/mobibot/modules/Dice.java index b68b579..f8cc7df 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/Dice.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/Dice.java @@ -43,7 +43,7 @@ import java.security.SecureRandom; * @created 2014-04-28 * @since 1.0 */ -final public class Dice extends AbstractModule { +public final class Dice extends AbstractModule { /** * The dice command. */ diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/GoogleSearch.java b/src/main/java/net/thauvin/erik/mobibot/modules/GoogleSearch.java index 9f4ca46..f0b705b 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/GoogleSearch.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/GoogleSearch.java @@ -51,7 +51,7 @@ import java.nio.charset.StandardCharsets; * @created Feb 7, 2004 * @since 1.0 */ -final public class GoogleSearch extends AbstractModule { +public final class GoogleSearch extends AbstractModule { /** * The google command. */ diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Joke.java b/src/main/java/net/thauvin/erik/mobibot/modules/Joke.java index 3588f29..285f54c 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/Joke.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/Joke.java @@ -48,7 +48,7 @@ import java.nio.charset.StandardCharsets; * @created 2014-04-20 * @since 1.0 */ -final public class Joke extends AbstractModule { +public final class Joke extends AbstractModule { /** * The joke command. */ diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Lookup.java b/src/main/java/net/thauvin/erik/mobibot/modules/Lookup.java index 89c9582..b2580a6 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/Lookup.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/Lookup.java @@ -45,7 +45,7 @@ import java.net.UnknownHostException; * @created 2014-04-26 * @since 1.0 */ -final public class Lookup extends AbstractModule { +public final class Lookup extends AbstractModule { /** * The lookup command. */ diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/StockQuote.java b/src/main/java/net/thauvin/erik/mobibot/modules/StockQuote.java index 8496c17..135373b 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/StockQuote.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/StockQuote.java @@ -46,7 +46,7 @@ import java.io.IOException; * @created Feb 7, 2004 * @since 1.0 */ -final public class StockQuote extends AbstractModule { +public final class StockQuote extends AbstractModule { /** * The quote command. */ diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/Twitter.java b/src/main/java/net/thauvin/erik/mobibot/modules/Twitter.java index b63a88c..db7c0bb 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/Twitter.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/Twitter.java @@ -43,17 +43,17 @@ import twitter4j.conf.ConfigurationBuilder; * @created Sept 10, 2008 * @since 1.0 */ -final public class Twitter extends AbstractModule { +public final class Twitter extends AbstractModule { /** * The twitter command. */ - public final static String TWITTER_CMD = "twitter"; + public static final String TWITTER_CMD = "twitter"; // The property keys. - private final static String CONSUMER_KEY_PROP = "twitter-consumerKey"; - private final static String CONSUMER_SECRET_PROP = "twitter-consumerSecret"; - private final static String TOKEN_PROP = "twitter-token"; - private final static String TOKEN_SECRET_PROP = "twitter-tokenSecret"; + private static final String CONSUMER_KEY_PROP = "twitter-consumerKey"; + private static final String CONSUMER_SECRET_PROP = "twitter-consumerSecret"; + private static final String TOKEN_PROP = "twitter-token"; + private static final String TOKEN_SECRET_PROP = "twitter-tokenSecret"; /** * Creates a new {@link Twitter} instance. diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/War.java b/src/main/java/net/thauvin/erik/mobibot/modules/War.java index 19c034a..4a063fd 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/War.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/War.java @@ -43,7 +43,7 @@ import java.security.SecureRandom; * @created 2014-04-28 * @since 1.0 */ -final public class War extends AbstractModule { +public final class War extends AbstractModule { /** * The war command */ @@ -95,7 +95,7 @@ final public class War extends AbstractModule { if (i < y) { bot.action("lost."); - } else if (i > y) { + } else { bot.action("wins."); } } diff --git a/src/main/java/net/thauvin/erik/mobibot/modules/WorldTime.java b/src/main/java/net/thauvin/erik/mobibot/modules/WorldTime.java index 02e680e..953ff7c 100644 --- a/src/main/java/net/thauvin/erik/mobibot/modules/WorldTime.java +++ b/src/main/java/net/thauvin/erik/mobibot/modules/WorldTime.java @@ -47,7 +47,7 @@ import java.util.TreeMap; * @created 2014-04-27 * @since 1.0 */ -final public class WorldTime extends AbstractModule { +public final class WorldTime extends AbstractModule { /** * The time command. */