diff --git a/config/spotbugs/excludeFilter.xml b/config/spotbugs/excludeFilter.xml
index 4590e4c..e2ac6d0 100644
--- a/config/spotbugs/excludeFilter.xml
+++ b/config/spotbugs/excludeFilter.xml
@@ -12,13 +12,19 @@
+
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/src/main/java/net/thauvin/erik/mobibot/FeedReader.java b/src/main/java/net/thauvin/erik/mobibot/FeedReader.java
index 53c3a15..e313e3f 100644
--- a/src/main/java/net/thauvin/erik/mobibot/FeedReader.java
+++ b/src/main/java/net/thauvin/erik/mobibot/FeedReader.java
@@ -33,7 +33,6 @@
package net.thauvin.erik.mobibot;
import com.rometools.rome.feed.synd.SyndEntry;
-import com.rometools.rome.feed.synd.SyndEntryImpl;
import com.rometools.rome.feed.synd.SyndFeed;
import com.rometools.rome.io.SyndFeedInput;
import com.rometools.rome.io.XmlReader;
@@ -87,10 +86,10 @@ class FeedReader implements Runnable {
final SyndFeed feed = input.build(new XmlReader(new URL(url)));
SyndEntry item;
- final List items = feed.getEntries();
+ final List items = feed.getEntries();
for (int i = 0; (i < items.size()) && (i < MAX_ITEMS); i++) {
- item = (SyndEntryImpl) items.get(i);
+ item = items.get(i);
bot.send(sender, item.getTitle());
bot.send(sender, TAB_INDENT + Utils.green(item.getLink()));
}
diff --git a/src/main/java/net/thauvin/erik/mobibot/TwitterOAuth.java b/src/main/java/net/thauvin/erik/mobibot/TwitterOAuth.java
index e84758c..f69fb8d 100644
--- a/src/main/java/net/thauvin/erik/mobibot/TwitterOAuth.java
+++ b/src/main/java/net/thauvin/erik/mobibot/TwitterOAuth.java
@@ -33,7 +33,7 @@ public final class TwitterOAuth {
*
* @param args The consumerKey and consumerSecret should be passed as arguments.
*/
- @SuppressFBWarnings(value = "DM_DEFAULT_ENCODING")
+ @SuppressFBWarnings({"DM_DEFAULT_ENCODING", "IMC_IMMATURE_CLASS_PRINTSTACKTRACE"})
public static void main(final String[] args)
throws Exception {
if (args.length == 2) {
diff --git a/src/main/java/net/thauvin/erik/mobibot/Utils.java b/src/main/java/net/thauvin/erik/mobibot/Utils.java
index d9ca5be..0b10b26 100644
--- a/src/main/java/net/thauvin/erik/mobibot/Utils.java
+++ b/src/main/java/net/thauvin/erik/mobibot/Utils.java
@@ -95,9 +95,9 @@ public final class Utils {
* @return The colorized string.
*/
static String colorize(final String s, final String color) {
- if (!Utils.isValidString(color) || color.equals(Colors.NORMAL)) {
+ if (!Utils.isValidString(color) || Colors.NORMAL.equals(color)) {
return s;
- } else if (color.equals(Colors.BOLD) || color.equals(Colors.REVERSE)) {
+ } else if (Colors.BOLD.equals(color) || Colors.REVERSE.equals(color)) {
return color + s + color;
}
@@ -247,14 +247,12 @@ public final class Utils {
* @return The unescaped string.
*/
public static String unescapeXml(final String str) {
- String s = str.replaceAll("&", "&");
- s = s.replaceAll("<", "<");
- s = s.replaceAll(">", ">");
- s = s.replaceAll(""", "\"");
- s = s.replaceAll("'", "'");
- s = s.replaceAll("'", "'");
-
- return s;
+ return str.replaceAll("&", "&")
+ .replaceAll("<", "<")
+ .replaceAll(">", ">")
+ .replaceAll(""", "\"")
+ .replaceAll("'", "'")
+ .replaceAll("'", "'");
}
/**
diff --git a/src/main/java/net/thauvin/erik/mobibot/entries/EntriesUtils.java b/src/main/java/net/thauvin/erik/mobibot/entries/EntriesUtils.java
index a43d30a..27526d3 100644
--- a/src/main/java/net/thauvin/erik/mobibot/entries/EntriesUtils.java
+++ b/src/main/java/net/thauvin/erik/mobibot/entries/EntriesUtils.java
@@ -32,6 +32,7 @@
package net.thauvin.erik.mobibot.entries;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.thauvin.erik.mobibot.Commands;
import net.thauvin.erik.mobibot.Constants;
import net.thauvin.erik.mobibot.Utils;
@@ -84,6 +85,7 @@ public final class EntriesUtils {
* @param isView Set to true to display the number of comments.
* @return The entry's link.
*/
+ @SuppressFBWarnings(value = "CE_CLASS_ENVY", justification = "Yes, it does.")
public static String buildLink(final int index, final EntryLink entry, final boolean isView) {
final StringBuilder buff = new StringBuilder(Commands.LINK_CMD + (index + 1) + ": ");
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 021060f..472367f 100644
--- a/src/main/java/net/thauvin/erik/mobibot/entries/EntryLink.java
+++ b/src/main/java/net/thauvin/erik/mobibot/entries/EntryLink.java
@@ -34,6 +34,7 @@ package net.thauvin.erik.mobibot.entries;
import com.rometools.rome.feed.synd.SyndCategory;
import com.rometools.rome.feed.synd.SyndCategoryImpl;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Serializable;
import java.util.Calendar;
@@ -291,6 +292,7 @@ public class EntryLink implements Serializable {
*
* @param tags The space-delimited tags.
*/
+ @SuppressFBWarnings(value = "STT_STRING_PARSING_A_FIELD")
public final void setTags(final String tags) {
if (tags != null) {
final String[] parts = tags.replaceAll(", ", " ").replaceAll(",", " ").split(" ");
@@ -310,7 +312,7 @@ public class EntryLink implements Serializable {
if (mod == '-') {
// Don't remove the channel tag, if any.
- if (!tag.getName().equals(channel.substring(1))) {
+ if (!channel.substring(1).equals(tag.getName())) {
this.tags.remove(tag);
}
} else if (mod == '+') {
@@ -334,7 +336,7 @@ public class EntryLink implements Serializable {
*
* @param tags The tags.
*/
- private void setTags(final List tags) {
+ final void setTags(final List tags) {
this.tags.addAll(tags);
}
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 190d50d..c23ddd1 100644
--- a/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.java
+++ b/src/main/java/net/thauvin/erik/mobibot/modules/CurrencyConverter.java
@@ -130,7 +130,7 @@ public final class CurrencyConverter extends ThreadedModule {
final String[] cmds = query.split(" ");
if (cmds.length == 4) {
- if (cmds[3].equals(cmds[1]) || cmds[0].equals("0")) {
+ if (cmds[3].equals(cmds[1]) || "0".equals(cmds[0])) {
return new ErrorMessage("You're kidding, right?");
} else {
try {
@@ -153,7 +153,7 @@ public final class CurrencyConverter extends ThreadedModule {
"The supported currencies are: " + EXCHANGE_RATES.keySet().toString(), e);
}
}
- } else if (query.equals(CURRENCY_RATES_KEYWORD)) {
+ } else if (CURRENCY_RATES_KEYWORD.equals(query)) {
final StringBuilder buff = new StringBuilder('[' + pubDate + "]: ");
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 95fe7ab..07cbdf9 100644
--- a/src/main/java/net/thauvin/erik/mobibot/modules/Joke.java
+++ b/src/main/java/net/thauvin/erik/mobibot/modules/Joke.java
@@ -107,7 +107,7 @@ public final class Joke extends ThreadedModule {
/**
* Returns a random joke from The Internet Chuck Norris Database.
*/
- void run(final Mobibot bot, final String sender, String arg) {
+ void run(final Mobibot bot, final String sender, final String arg) {
try {
bot.send(Utils.cyan(randomJoke().getMessage()));
} catch (ModuleException e) {
diff --git a/src/main/java/net/thauvin/erik/mobibot/msg/Message.java b/src/main/java/net/thauvin/erik/mobibot/msg/Message.java
index 47c3f1e..6a9bf20 100644
--- a/src/main/java/net/thauvin/erik/mobibot/msg/Message.java
+++ b/src/main/java/net/thauvin/erik/mobibot/msg/Message.java
@@ -178,7 +178,7 @@ public class Message {
*
* @param isPrivate The private flag.
*/
- public void setPrivate(boolean isPrivate) {
+ public void setPrivate(final boolean isPrivate) {
this.isPrivate = isPrivate;
}
}
diff --git a/src/main/java/net/thauvin/erik/mobibot/tell/Tell.java b/src/main/java/net/thauvin/erik/mobibot/tell/Tell.java
index 66c6cc4..dec97fa 100644
--- a/src/main/java/net/thauvin/erik/mobibot/tell/Tell.java
+++ b/src/main/java/net/thauvin/erik/mobibot/tell/Tell.java
@@ -32,6 +32,7 @@
package net.thauvin.erik.mobibot.tell;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.thauvin.erik.mobibot.Commands;
import net.thauvin.erik.mobibot.Mobibot;
import net.thauvin.erik.mobibot.Utils;
@@ -100,7 +101,8 @@ public class Tell {
*
* @return true
if the queue was cleaned.
*/
- private boolean clean() {
+ @SuppressWarnings("WeakerAccess")
+ final boolean clean() {
if (bot.getLogger().isDebugEnabled()) {
bot.getLogger().debug("Cleaning the messages.");
}
@@ -138,12 +140,13 @@ public class Tell {
* @param sender The sender's nick.
* @param cmds The commands string.
*/
+ @SuppressFBWarnings(value = "CC_CYCLOMATIC_COMPLEXITY", justification = "Working on it.")
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 (bot.isOp(sender) && (Commands.VIEW_CMD + ' ' + TELL_ALL_KEYWORD).equals(cmds)) {
if (!messages.isEmpty()) {
for (final TellMessage message : messages) {
bot.send(sender, Utils.bold(message.getSender()) + arrow + Utils.bold(message.getRecipient())
@@ -201,7 +204,7 @@ public class Tell {
final String id = split[1];
boolean deleted = false;
- if (id.equalsIgnoreCase(TELL_ALL_KEYWORD)) {
+ if (TELL_ALL_KEYWORD.equalsIgnoreCase(id)) {
for (final TellMessage message : messages) {
if (message.getSender().equalsIgnoreCase(sender) && message.isReceived()) {
messages.remove(message);
@@ -272,7 +275,8 @@ public class Tell {
/**
* Saves the messages queue.
*/
- private void save() {
+ @SuppressWarnings("WeakerAccess")
+ final void save() {
TellMessagesMgr.save(serializedObject, messages, bot.getLogger());
}
diff --git a/src/test/java/net/thauvin/erik/mobibot/entries/EntryLinkTest.java b/src/test/java/net/thauvin/erik/mobibot/entries/EntryLinkTest.java
index fd3edac..fd0650d 100644
--- a/src/test/java/net/thauvin/erik/mobibot/entries/EntryLinkTest.java
+++ b/src/test/java/net/thauvin/erik/mobibot/entries/EntryLinkTest.java
@@ -84,7 +84,7 @@ public class EntryLinkTest {
final List tags = entryLink.getTags();
int i = 0;
- for (SyndCategory tag : tags) {
+ for (final SyndCategory tag : tags) {
assertThat(tag.getName()).as("tag.getName(" + i + ')').isEqualTo("tag" + (i + 1));
i++;
}
diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/AbstractModuleTest.java b/src/test/java/net/thauvin/erik/mobibot/modules/AbstractModuleTest.java
index eb678c5..b28d3f4 100644
--- a/src/test/java/net/thauvin/erik/mobibot/modules/AbstractModuleTest.java
+++ b/src/test/java/net/thauvin/erik/mobibot/modules/AbstractModuleTest.java
@@ -32,6 +32,8 @@
package net.thauvin.erik.mobibot.modules;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
import static org.assertj.core.api.Assertions.assertThat;
/**
@@ -41,7 +43,9 @@ import static org.assertj.core.api.Assertions.assertThat;
* @created 2019-04-07
* @since 1.0
*/
+
final class AbstractModuleTest {
+ @SuppressFBWarnings("CE_CLASS_ENVY")
static void testAbstractModule(final AbstractModule module) {
final String name = module.getClass().getName();
diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/GoogleSearchTest.java b/src/test/java/net/thauvin/erik/mobibot/modules/GoogleSearchTest.java
index 92d63ae..c81b883 100644
--- a/src/test/java/net/thauvin/erik/mobibot/modules/GoogleSearchTest.java
+++ b/src/test/java/net/thauvin/erik/mobibot/modules/GoogleSearchTest.java
@@ -32,6 +32,7 @@
package net.thauvin.erik.mobibot.modules;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.thauvin.erik.mobibot.msg.Message;
import org.testng.annotations.Test;
@@ -52,6 +53,7 @@ public class GoogleSearchTest extends LocalProperties {
AbstractModuleTest.testAbstractModule(new GoogleSearch());
}
+ @SuppressFBWarnings("LEST_LOST_EXCEPTION_STACK_TRACE")
@Test
public void testSearchGoogle() throws ModuleException {
final String apiKey = LocalProperties.getProperty(GoogleSearch.GOOGLE_API_KEY_PROP);
diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/StockQuoteTest.java b/src/test/java/net/thauvin/erik/mobibot/modules/StockQuoteTest.java
index fc2ccec..b4fff14 100644
--- a/src/test/java/net/thauvin/erik/mobibot/modules/StockQuoteTest.java
+++ b/src/test/java/net/thauvin/erik/mobibot/modules/StockQuoteTest.java
@@ -32,6 +32,7 @@
package net.thauvin.erik.mobibot.modules;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.thauvin.erik.mobibot.msg.Message;
import org.testng.annotations.Test;
@@ -46,7 +47,9 @@ import static org.assertj.core.api.Assertions.assertThat;
* @created 2019-04-07
* @since 1.0
*/
+
public class StockQuoteTest extends LocalProperties {
+ @SuppressFBWarnings("LEST_LOST_EXCEPTION_STACK_TRACE")
@Test
public void testGetQuote() throws ModuleException {
final String apiKey = LocalProperties.getProperty(StockQuote.ALPHAVANTAGE_API_KEY_PROP);
diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/TwitterTest.java b/src/test/java/net/thauvin/erik/mobibot/modules/TwitterTest.java
index 3293956..cf64b4d 100644
--- a/src/test/java/net/thauvin/erik/mobibot/modules/TwitterTest.java
+++ b/src/test/java/net/thauvin/erik/mobibot/modules/TwitterTest.java
@@ -32,6 +32,7 @@
package net.thauvin.erik.mobibot.modules;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.thauvin.erik.mobibot.Constants;
import org.testng.annotations.Test;
@@ -48,6 +49,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 1.0
*/
public class TwitterTest {
+ @SuppressFBWarnings("MDM")
private String getCi() {
if ("true".equals(System.getenv("CIRCLECI"))) {
return "CircleCI";
diff --git a/src/test/java/net/thauvin/erik/mobibot/modules/Weather2Test.java b/src/test/java/net/thauvin/erik/mobibot/modules/Weather2Test.java
index 97e395f..2ac1b0a 100644
--- a/src/test/java/net/thauvin/erik/mobibot/modules/Weather2Test.java
+++ b/src/test/java/net/thauvin/erik/mobibot/modules/Weather2Test.java
@@ -32,6 +32,7 @@
package net.thauvin.erik.mobibot.modules;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import net.thauvin.erik.mobibot.msg.Message;
import org.testng.annotations.Test;
@@ -47,6 +48,7 @@ import static org.assertj.core.api.Assertions.assertThat;
* @since 1.0
*/
public class Weather2Test extends LocalProperties {
+ @SuppressFBWarnings("PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS")
@Test
public void testWeather() throws ModuleException {
ArrayList messages = Weather2.getWeather("98204",