@ZaydM18 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/monty/ui/MainWindow.java lines 63-161:
private void handleUserInput() {
String input = userInput.getText().trim();
if (input.isEmpty()) {
return;
}
String response;
try {
StringBuilder capturedOutput = new StringBuilder();
Ui guiUi = new Ui() {
@Override
public void showError(String message) {
capturedOutput.append("❌ ").append(message).append("\n");
}
@Override
public void showTaskAdded(Task task, int size) {
capturedOutput.append("✔ Task added: ").append(task.toString()).append("\n")
.append("Now you have ").append(size).append(" tasks in the list.\n");
}
@Override
public void showTaskDeleted(Task task, int size) {
capturedOutput.append("🗑 Task removed: ").append(task.toString()).append("\n")
.append("Now you have ").append(size).append(" tasks in the list.\n");
}
@Override
public void showTaskMarked(Task task) {
capturedOutput.append("✅ Task marked as done: ").append(task.toString()).append("\n");
}
@Override
public void showTaskUnmarked(Task task) {
capturedOutput.append("🔄 Task marked as not done: ").append(task.toString()).append("\n");
}
@Override
public void showTaskList(java.util.List<Task> tasks) {
capturedOutput.append("📋 Here are the tasks in your list:\n");
for (int i = 0; i < tasks.size(); i++) {
capturedOutput.append((i + 1)).append(". ").append(tasks.get(i)).append("\n");
}
capturedOutput.append("...\n");
}
@Override
public void showNoTasksFoundForDate() {
capturedOutput.append("📅 No deadlines or events found on this date. Maybe you should make some?\n");
}
@Override
public void showTasksForDate(LocalDate date, java.util.List<Task> tasks) {
capturedOutput.append("📅 Here are the deadlines and events on ")
.append(date.format(DateTimeFormatter.ofPattern("MMM dd yyyy"))).append(":\n");
for (Task task : tasks) {
capturedOutput.append(" ").append(task).append("\n");
}
}
@Override
public void showFoundTasks(Task... matchingTasks) {
if (matchingTasks.length == 0) {
capturedOutput.append("🔍 No matching tasks found.\n");
} else {
capturedOutput.append("🔍 Here are the matching tasks:\n");
for (int i = 0; i < matchingTasks.length; i++) {
capturedOutput.append((i + 1)).append(". ").append(matchingTasks[i]).append("\n");
}
capturedOutput.append("...\n");
}
}
@Override
public void showGoodbye() {
capturedOutput.append("👋 Bye. Hope to see you again soon!\n");
}
};
try {
Parser.processCommand(input, tasks, guiUi);
Storage.saveTasks(tasks);
response = capturedOutput.toString();
} catch (IllegalArgumentException e) {
response = "❌ Invalid date format! Please use yyyy-MM-dd HHmm.\n";
} catch (MontyException e) {
response = "❌ " + e.getMessage();
}
} catch (Exception e) {
response = "❌ An unexpected error occurred.";
e.printStackTrace();
}
appendToDialog("You", input);
appendToDialog("Monty", response);
userInput.clear();
}
Example from src/main/java/monty/parser/Parser.java lines 27-119:
public static void processCommand(String userInput, ArrayList<Task> tasks, Ui ui) throws MontyException {
String[] words = userInput.split(" ", 2);
String command = words[0];
String argument = words.length > 1 ? words[1].trim() : "";
switch (command) {
case "bye": {
ui.showGoodbye();
Storage.saveTasks(tasks);
return;
}
case "list": {
ui.showTaskList(tasks);
break;
}
case "mark": {
int markIndex = validateTaskIndex(argument, tasks.size());
tasks.get(markIndex).markAsDone();
ui.showTaskMarked(tasks.get(markIndex));
Storage.saveTasks(tasks);
break;
}
case "unmark": {
int unmarkIndex = validateTaskIndex(argument, tasks.size());
tasks.get(unmarkIndex).markAsNotDone();
ui.showTaskUnmarked(tasks.get(unmarkIndex));
Storage.saveTasks(tasks);
break;
}
case "todo": {
if (argument.isEmpty()) {
throw new MontyException("Huh? You just left that description blank, friend. How can one make a list with this?");
}
Task newToDo = new ToDo(argument);
tasks.add(newToDo);
ui.showTaskAdded(newToDo, tasks.size());
Storage.saveTasks(tasks);
break;
}
case "deadline": {
if (!argument.contains(" /by ")) {
throw new MontyException("Deadlines must include a '/by' followed by a date and time (yyyy-MM-dd HHmm).");
}
String[] deadlineParts = argument.split(" /by ", 2);
Task newDeadline = new Deadline(deadlineParts[0], deadlineParts[1]);
tasks.add(newDeadline);
ui.showTaskAdded(newDeadline, tasks.size());
Storage.saveTasks(tasks);
break;
}
case "event": {
if (!argument.contains(" /from ") || !argument.contains(" /to ")) {
throw new MontyException("Events must include '/from' and '/to' with a date and time (yyyy-MM-dd HHmm).");
}
String[] eventParts = argument.split(" /from | /to ", 3);
Task newEvent = new Event(eventParts[0], eventParts[1], eventParts[2]);
tasks.add(newEvent);
ui.showTaskAdded(newEvent, tasks.size());
Storage.saveTasks(tasks);
break;
}
case "date": {
processDateCommand(argument, tasks, ui);
break;
}
case "delete": {
int deleteIndex = validateTaskIndex(argument, tasks.size());
Task removedTask = tasks.remove(deleteIndex);
ui.showTaskDeleted(removedTask, tasks.size());
Storage.saveTasks(tasks);
break;
}
case "find":
processFindCommand(argument, tasks, ui);
break;
default: {
throw new MontyException("What are you saying? Please tell me again. I must add it to the list!");
}
}
}
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
Example from src/main/java/monty/Monty.java lines 57-61:
/**
* The entry point for the Monty application.
*
* @param args Command-line arguments (not used in this application).
*/
Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
Aspect: Recent Git Commit Messages
possible problems in commit 0d9e2e5:
Add GUI.
Add VarArg functionality.
- Subject line should not end with a period
possible problems in commit 6350ddb:
Add filler to use tag.
Follow git standard (to the best of my knowledge).
- Subject line should not end with a period
possible problems in commit bfee621:
Add 'find' feature to Parser class.
Edit Ui class to include message for the 'find' feature.
- Subject line should not end with a period
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.
@ZaydM18 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/monty/ui/MainWindow.javalines63-161:Example from
src/main/java/monty/parser/Parser.javalines27-119: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
Example from
src/main/java/monty/Monty.javalines57-61:Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
Aspect: Recent Git Commit Messages
possible problems in commit
0d9e2e5:possible problems in commit
6350ddb:possible problems in commit
bfee621: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.