@sandyk0105 We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the iP code further.
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
No easy-to-detect issues 👍
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
No easy-to-detect issues 👍
Aspect: Method Length
Example from src/main/java/rei/Parser.java lines 40-143:
public static Prompt parse(TaskList tasks, String prompt) {
List<String> prompts = Arrays.asList(prompt.split(" "));
String taskDetails;
switch (prompts.get(0)) {
case "list":
return Prompt.LIST;
case "mark":
// Read the rest of the line after "mark"
taskDetails = prompt.substring(MARK_COMMAND_LENGTH).trim();
// Check if the rest of the line is an integer
if (taskDetails.isEmpty() || !taskDetails.matches("\\d+")) {
Ui.print("State the task number.");
return Prompt.UNKNOWN;
}
return Prompt.MARK;
case "unmark":
// Read the rest of the line after "unmark"
taskDetails = prompt.substring(UNMARK_COMMAND_LENGTH).trim();
// Check if the rest of the line is an integer
if (taskDetails.isEmpty() || !taskDetails.matches("\\d+")) {
Ui.print("State the task number.");
return Prompt.UNKNOWN;
}
return Prompt.UNMARK;
case "todo":
if (isAllWhitespace(prompt.substring(TODO_COMMAND_LENGTH))) {
Ui.print("Task is empty. Please state the task name.");
return Prompt.UNKNOWN;
}
return Prompt.TODO;
case "deadline":
if (isAllWhitespace(prompt.substring(DEADLINE_COMMAND_LENGTH))) {
Ui.print("Task is empty. Please state the task and deadline.");
return Prompt.UNKNOWN;
} else if (prompt.indexOf("/by") == -1) {
Ui.print("When is the deadline? Please state the task with the deadline.");
return Prompt.UNKNOWN;
} else if (isAllWhitespace(prompt.substring(8, prompt.indexOf("/by")))) {
Ui.print("Task name is empty. Please state the task and deadline.");
return Prompt.UNKNOWN;
}
try {
LocalDateTime.parse(prompt.substring(prompt.indexOf("/by") + 4));
} catch (DateTimeParseException e) {
Ui.print("Wrong date format : YYYY-MM-DDTHH:MM \n For example, 2024-09-12T18:00");
return Prompt.UNKNOWN;
}
return Prompt.DEADLINE;
case "event":
if (isAllWhitespace(prompt.substring(EVENT_COMMAND_LENGTH))) {
Ui.print("Event is empty. Please state the event and time range.");
return Prompt.UNKNOWN;
} else if (prompt.indexOf("/from") == -1 || prompt.indexOf("/to") == -1) {
Ui.print("State the START and FINISH time of the event");
return Prompt.UNKNOWN;
} else if (isAllWhitespace(prompt.substring(5, prompt.indexOf("/from")))) {
Ui.print("Task name is empty. Please state the task and event time.");
return Prompt.UNKNOWN;
}
try {
LocalDateTime.parse(prompt.substring(prompt.indexOf("/from") + 6, prompt.indexOf("/to") - 1));
LocalDateTime.parse(prompt.substring(prompt.indexOf("/to") + 4));
} catch (DateTimeParseException e) {
Ui.print("Wrong date format : YYYY-MM-DDTHH:MM \n For example, 2024-09-12T18:00");
return Prompt.UNKNOWN;
}
return Prompt.EVENT;
case "delete":
// Read the rest of the line after "delete"
taskDetails = prompt.substring(DELETE_COMMAND_LENGTH).trim();
// Check if the rest of the line is an integer
if (taskDetails.isEmpty() || !taskDetails.matches("\\d+")) {
Ui.print("State the task number.");
return Prompt.UNKNOWN;
}
return Prompt.DELETE;
case "find":
// Read the rest of the line after "find"
prompt = prompt.substring(FIND_COMMAND_LENGTH).trim();
if (prompt.isEmpty()) {
Ui.print("State the keyword");
return Prompt.UNKNOWN;
}
return Prompt.FIND;
case "annyeong":
Ui.print("Annyeong. Hope to see you soon.");
return Prompt.ANNYEONG;
default:
Ui.print("I don't understand what you want me to do.");
return Prompt.UNKNOWN;
}
}
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 Message
possible problems in commit c559f96:
A-Jar
Package Rei bot into JAR file using Gradle shadowJar
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 👍
ℹ️ 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.
@sandyk0105 We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the iP code further.
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
No easy-to-detect issues 👍
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
No easy-to-detect issues 👍
Aspect: Method Length
Example from
src/main/java/rei/Parser.javalines40-143: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 Message
possible problems in commit
c559f96: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 👍
ℹ️ 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.