@Strikerprv We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, so that you can avoid similar problems in your tP code (which will be graded more strictly for code quality).
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.
Aspect: Tab Usage
No easy-to-detect issues 👍
Aspect: Naming boolean variables/methods
Example from src/main/java/dukeychatbot/TaskList.java lines 43-43:
boolean taskIsDone = false;
Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)
Aspect: Brace Style
No easy-to-detect issues 👍
Aspect: Package Name Style
No easy-to-detect issues 👍
Aspect: Class Name Style
No easy-to-detect issues 👍
Aspect: Dead Code
Example from src/main/java/Test.java lines 1-1:
Example from src/main/java/Test.java lines 2-2:
// public static void main(String[] args) throws DukeyException {
Example from src/main/java/Test.java lines 3-3:
Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from src/main/java/dukeychatbot/TaskList.java lines 36-86:
private void initialiseTasks(ArrayList<String> taskList) {
for (String input : taskList) {
try {
// Need to format the input string so that it resembles a command
StringBuilder formattedCommand = new StringBuilder();
String[] inputArray = input.split(" ");
boolean taskIsDone = false;
if (inputArray[1].length() != 1) {
taskIsDone = true;
}
// Split according to the two [] and only retain the description portion
String description = input.split("]")[2].trim();
String type = String.valueOf(inputArray[0].charAt(1));
switch (type) {
case "T" -> {
formattedCommand.append("todo ");
formattedCommand.append(description);
}
case "D" -> {
formattedCommand.append("deadline ");
String[] splitDescription = description.split("\\(by:");
String deadline = splitDescription[1].trim();
String formattedDescription = splitDescription[0].trim() + " /by "
+ deadline.substring(0, deadline.length() - 1);
formattedCommand.append(formattedDescription);
}
case "E" -> {
formattedCommand.append("event ");
String[] splitDescription = description.split("\\(from:");
String taskDescription = splitDescription[0].trim();
String[] timePeriod = splitDescription[1].split("to:");
String fromTime = timePeriod[0].trim();
String toTime = timePeriod[1].trim();
toTime = toTime.substring(0, toTime.length() - 1);
String compiledCommand = taskDescription + " /from " + fromTime + " /to " + toTime;
formattedCommand.append(compiledCommand);
}
default -> {
throw new InvalidCommandException();
}
}
this.addNewTask(formattedCommand.toString(), taskIsDone, true);
} catch (InvalidCommandException | EmptyDescriptionException | MissingDeadlineException
| MissingTimeframeException e) {
System.out.println(e.getMessage());
}
}
}
Example from src/main/java/dukeychatbot/Parser.java lines 37-73:
public String parse(String fullCommand) {
String command = fullCommand.trim();
if (command.equalsIgnoreCase("bye") || command.equalsIgnoreCase("b")) {
return this.byeCommand();
} else if (command.equalsIgnoreCase("list") || command.equalsIgnoreCase("li")) {
return this.ui.printList("", taskArray.getTasks());
} else if (command.split(" ").length == 2) {
try {
String commandWord = command.split(" ")[0];
if (commandWord.equalsIgnoreCase("mark")
|| commandWord.equalsIgnoreCase("m")) {
int taskNumber = Integer.parseInt(command.split(" ")[1]);
return this.markCommand(taskNumber);
} else if (commandWord.equalsIgnoreCase("unmark")
|| commandWord.equalsIgnoreCase("unm")) {
int taskNumber = Integer.parseInt(command.split(" ")[1]);
return this.unmarkCommand(taskNumber);
} else if (commandWord.equalsIgnoreCase("delete")
|| commandWord.equalsIgnoreCase("del")) {
int taskNumber = Integer.parseInt(command.split(" ")[1]);
return this.delete(taskNumber);
} else if (commandWord.equalsIgnoreCase("find")
|| commandWord.equalsIgnoreCase("f")) {
String keyword = command.split(" ")[1];
return this.find(keyword);
}
} catch (NumberFormatException e) {
return this.ui.numberFormatError();
}
}
try {
return this.taskArray.addNewTask(command, false, false);
} catch (InvalidCommandException | EmptyDescriptionException | MissingDeadlineException
| MissingTimeframeException e) {
return this.ui.formattedErrorResponse(e.getMessage());
}
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods e.g., extract some code blocks into separate methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
Aspect: Class size
No easy-to-detect issues 👍
Aspect: Header Comments
No easy-to-detect issues 👍
Aspect: Recent Git Commit Messages
possible problems in commit af0fc76:
Amend UI output of chatbox to craft Pikachu personality
Chatbot provided too standard, robotic responses which would make the user experience less dynamic.
Integrating Pikachu phrases makes the chatbot more Pikachu-like and more interactive.
ChatGPT was used as it helped to amend the UI outputs to integrate the Pikachu phrases of "pika"
while not making it appear unnatural and awkward.
- body not wrapped at 72 characters: e.g.,
Chatbot provided too standard, robotic responses which would make the user experience less dynamic.
Suggestion: Follow the given conventions for Git commit messages for future commits (do not modify past commit messages as doing so will change the commit timestamp that we used to detect your commit timings).
Aspect: Binary files in repo
No easy-to-detect issues 👍
❗ You are not required to (but you are welcome to) fix the above problems in your iP, unless you have been separately asked to resubmit the iP due to code quality issues.
ℹ️ The bot account used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact cs2103@comp.nus.edu.sg if you want to follow up on this post.
@Strikerprv We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, so that you can avoid similar problems in your tP code (which will be graded more strictly for code quality).
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.
Aspect: Tab Usage
No easy-to-detect issues 👍
Aspect: Naming boolean variables/methods
Example from
src/main/java/dukeychatbot/TaskList.javalines43-43:Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)
Aspect: Brace Style
No easy-to-detect issues 👍
Aspect: Package Name Style
No easy-to-detect issues 👍
Aspect: Class Name Style
No easy-to-detect issues 👍
Aspect: Dead Code
Example from
src/main/java/Test.javalines1-1://public class Test {Example from
src/main/java/Test.javalines2-2:// public static void main(String[] args) throws DukeyException {Example from
src/main/java/Test.javalines3-3:// return;Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from
src/main/java/dukeychatbot/TaskList.javalines36-86:Example from
src/main/java/dukeychatbot/Parser.javalines37-73:Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods e.g., extract some code blocks into separate methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
Aspect: Class size
No easy-to-detect issues 👍
Aspect: Header Comments
No easy-to-detect issues 👍
Aspect: Recent Git Commit Messages
possible problems in commit
af0fc76:Chatbot provided too standard, robotic responses which would make the user experience less dynamic.Suggestion: Follow the given conventions for Git commit messages for future commits (do not modify past commit messages as doing so will change the commit timestamp that we used to detect your commit timings).
Aspect: Binary files in repo
No easy-to-detect issues 👍
❗ You are not required to (but you are welcome to) fix the above problems in your iP, unless you have been separately asked to resubmit the iP due to code quality issues.
ℹ️ The bot account used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact
cs2103@comp.nus.edu.sgif you want to follow up on this post.