You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@pkpaing 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.
publicstaticStringhandleCommand(Strings, TaskListt) {
ArrayList<Task> tasks = t.getTasks();
intnumTasks = tasks.size();
assertnumTasks >= 0 : "Number of tasks should be a positive number";
asserts.length() >= 0 : "Number of letters in a command should be a positive number";
// user enters list commandif (s.contains("list")) {
returnt.displayTasks();
// user enters mark or unmark command
} elseif (s.contains("mark") || s.contains("unmark")) {
inttaskNumber = Integer.parseInt(s.substring(s.length() - 1)) - 1;
tasks.get(taskNumber).toggleMarked();
Stringoutput = "";
if (s.contains("unmark")) {
output += " OK, I've marked this task as not done yet:";
} else {
output += " Nice! I've marked this task as done:";
}
returnoutput + " " + tasks.get(taskNumber).toString();
// user enters a new task
} elseif (s.contains("todo")) {
if (s.substring(4).isBlank()) {
return" OOPS!!! The description of a todo cannot be empty.";
} else {
TasknewTask = newTodo(s.substring(5));
tasks.add(newTask);
return" added: " + newTask;
}
} elseif (s.contains("deadline")) {
if (s.substring(8).isBlank()) {
return" OOPS!!! The description of a deadline cannot be empty.";
} else {
Stringby = s.substring(s.indexOf("/") + 4);
TasknewTask = newDeadline(s.substring(9, s.indexOf("/") - 1), by);
tasks.add(newTask);
return" added: " + newTask;
}
} elseif (s.contains("event")) {
if (s.substring(5).isBlank()) {
return" OOPS!!! The description of a event cannot be empty.";
} else {
Stringfrom = s.substring(s.indexOf("/") + 6, s.lastIndexOf("/") - 1);
Stringto = s.substring(s.lastIndexOf("/") + 4);
TasknewTask = newEvent(s.substring(6, s.indexOf("/") - 1), from, to);
tasks.add(newTask);
return" added: " + newTask;
}
} elseif (s.contains("delete")) {
if (s.substring(6).isBlank()) {
return" OOPS!!! You have not entered anything to delete.";
} else {
inttaskNumber = Integer.parseInt(s.substring(s.length() - 1)) - 1;
TaskdeletedTask = tasks.get(taskNumber);
tasks.remove(taskNumber);
return" Noted. I've removed this task:\n " + deletedTask +
"\n Now you have " + tasks.size()+ " tasks in the list";
}
} elseif (s.contains("find")) {
StringfindString = s.substring(5);
ArrayList<Task> foundTasks = newArrayList<Task>();
for (Tasktask : tasks) {
if (task.toString().contains(findString)) {
foundTasks.add(task);
}
}
TaskListsearchResults = newTaskList(foundTasks);
return"Here are the tasks I found!\n" + searchResults.displayTasks();
// make displayTasks return a String
} elseif (s.contains("sort")) {
returnt.displaySorted();
} elseif (s.contains("bye")) {
return" Bye. Hope to see you soon!";
} else {
//throw new duke.DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");return" OOPS!!! I'm sorry, but I don't know what that means :-(";
}
}
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.
/** * Iteration 1: * Creates a label with the specified text and adds it to the dialog container. * @param text String containing text to add * @return a label with the specified text that has word wrap enabled. */
/** * Iteration 2: * Creates two dialog boxes, one echoing user input and the other containing Duke's reply and then appends them to * the dialog container. Clears the user input after processing. */
/** * You should have your own function to generate a response to user input. * Replace this stub with your completed method. */
Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.
ℹ️ 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 [email protected] if you want to follow up on this post.
The text was updated successfully, but these errors were encountered:
@pkpaing 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
Example from
src/main/java/duke/Ui.java
lines98-98
://throw new duke.DukeException("OOPS!!! I'm sorry, but I don't know what that means :-(");
Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from
src/main/java/duke/Duke.java
lines33-98
:Example from
src/main/java/duke/Ui.java
lines18-101
: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/duke/Duke.java
lines99-104
:Example from
src/main/java/duke/Duke.java
lines112-116
:Example from
src/main/java/duke/Duke.java
lines133-136
: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 Message (Subject Only)
possible problems in commit
f1473ba
:Added Sort command which sorts the displayed task based on whether it's a Todo, Deadline or Event
possible problems in commit
6225d45
:Added assertions into several class files
possible problems in commit
84905c6
:Merged Level-10 and A-CheckStyle into Master
Suggestion: Follow the given conventions for Git commit messages for future commits (no need to modify past commit messages).
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
[email protected]
if you want to follow up on this post.The text was updated successfully, but these errors were encountered: