From c38e98761133b82d70010ce2f030295478bedc8a Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 14 Dec 2017 17:11:52 +0100 Subject: [PATCH] Made code review. --- src/main/java/fr/imirhil/april/hebdobot/Application.java | 2 +- .../fr/imirhil/april/hebdobot/pastebin/PastebinClient.java | 2 +- .../fr/imirhil/april/hebdobot/review/CollectiveTopic.java | 4 +++- .../fr/imirhil/april/hebdobot/review/IndividualTopic.java | 4 +++- src/main/java/fr/imirhil/april/hebdobot/review/Message.java | 3 ++- src/main/java/fr/imirhil/april/hebdobot/xml/UserAlias.java | 6 +++--- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/main/java/fr/imirhil/april/hebdobot/Application.java b/src/main/java/fr/imirhil/april/hebdobot/Application.java index 6b2845e..5c9844a 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/Application.java +++ b/src/main/java/fr/imirhil/april/hebdobot/Application.java @@ -83,7 +83,7 @@ public class Application implements ReviewListener { try { - final File file = new File(date + "_" + this.properties.getProperty(FILE_SUFFIX)); + File file = new File(date + "_" + this.properties.getProperty(FILE_SUFFIX)); FileUtils.writeStringToFile(file, text); this.bot.sendMessage("% Compte-rendu de la revue : " + file.getName()); } diff --git a/src/main/java/fr/imirhil/april/hebdobot/pastebin/PastebinClient.java b/src/main/java/fr/imirhil/april/hebdobot/pastebin/PastebinClient.java index 677168b..93d822f 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/pastebin/PastebinClient.java +++ b/src/main/java/fr/imirhil/april/hebdobot/pastebin/PastebinClient.java @@ -56,7 +56,7 @@ public class PastebinClient public static final String API_ERROR = "Bad API request,"; private final String apiKey; - private String apiUserKey = null; + private String apiUserKey; private HttpClient httpClient = new DefaultHttpClient(); diff --git a/src/main/java/fr/imirhil/april/hebdobot/review/CollectiveTopic.java b/src/main/java/fr/imirhil/april/hebdobot/review/CollectiveTopic.java index 4557828..20bbf79 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/review/CollectiveTopic.java +++ b/src/main/java/fr/imirhil/april/hebdobot/review/CollectiveTopic.java @@ -28,7 +28,7 @@ import java.util.Set; */ public class CollectiveTopic extends Topic { - private final Messages messages = new Messages(); + private final Messages messages; /** * Instantiates a new collective topic. @@ -39,6 +39,8 @@ public class CollectiveTopic extends Topic public CollectiveTopic(final String title) { super(title); + + this.messages = new Messages(); } /* (non-Javadoc) diff --git a/src/main/java/fr/imirhil/april/hebdobot/review/IndividualTopic.java b/src/main/java/fr/imirhil/april/hebdobot/review/IndividualTopic.java index 4387f65..a17dfa0 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/review/IndividualTopic.java +++ b/src/main/java/fr/imirhil/april/hebdobot/review/IndividualTopic.java @@ -28,7 +28,7 @@ import java.util.Set; */ public class IndividualTopic extends Topic { - private final Map messages = new HashMap(); + private final Map messages; /** * Instantiates a new individual topic. @@ -39,6 +39,8 @@ public class IndividualTopic extends Topic public IndividualTopic(final String title) { super(title); + + this.messages = new HashMap(); } /* (non-Javadoc) diff --git a/src/main/java/fr/imirhil/april/hebdobot/review/Message.java b/src/main/java/fr/imirhil/april/hebdobot/review/Message.java index fcf7399..ab19ee5 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/review/Message.java +++ b/src/main/java/fr/imirhil/april/hebdobot/review/Message.java @@ -26,7 +26,7 @@ import org.joda.time.DateTime; */ public class Message { - private final DateTime date = new DateTime(); + private final DateTime date; private final String author; private final String content; @@ -42,6 +42,7 @@ public class Message { this.author = author; this.content = content; + this.date = new DateTime(); } /** diff --git a/src/main/java/fr/imirhil/april/hebdobot/xml/UserAlias.java b/src/main/java/fr/imirhil/april/hebdobot/xml/UserAlias.java index 6911205..b890f8d 100644 --- a/src/main/java/fr/imirhil/april/hebdobot/xml/UserAlias.java +++ b/src/main/java/fr/imirhil/april/hebdobot/xml/UserAlias.java @@ -51,11 +51,11 @@ public class UserAlias { try { - final Unmarshaller u = JAXBContext.newInstance(Users.class).createUnmarshaller(); - u.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) + final Unmarshaller unmarshaller = JAXBContext.newInstance(Users.class).createUnmarshaller(); + unmarshaller.setSchema(SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) .newSchema(UserAlias.class.getResource("/fr/imirhil/april/hebdobot/users.xsd"))); - for (final User user : u.unmarshal(new StreamSource(source), Users.class).getValue().getUser()) + for (final User user : unmarshaller.unmarshal(new StreamSource(source), Users.class).getValue().getUser()) { final String realName = user.getRealName(); for (final String nick : user.getNick())