@alextang809 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
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.java
lines 19-19
:
Example from src/main/java/Duke.java
lines 27-27
:
// switch (splitMessage[0]) {
Example from src/main/java/Duke.java
lines 29-29
:
// Task.printHorizontalLine();
Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from src/main/java/Duke.java
lines 6-88
:
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
printWelcomeMessage();
Scanner in = new Scanner(System.in);
Task[] taskList = new Task[MAX_TASK]; //ask[] taskList = new Task[100];
//int taskCounter = 0;
// use while loop to deal with user input through scanner
String msgDescription; //String line; Line // msgDescription
request:
while (true) {
msgDescription = in.nextLine();
String[] splitMessage = msgDescription.split(" ");
// switch (splitMessage[0]) {
if (Objects.equals(msgDescription, "list")) {
// Task.printHorizontalLine();
// System.out.println("Here are the tasks in your list:");
// for (int i = 0; i < Task.getTotalNumberOfTask(); i++) {
// taskList[i].printTaskList(taskList);
// }
// Task.printHorizontalLine();
Task.printTaskList(taskList);
} else if (Objects.equals(msgDescription, "blah")) {
printBlahMessage();
} else if (Objects.equals(msgDescription, "bye")) {
Duke.printByeMessage();
break request;
} else if (Objects.equals(msgDescription.split(" ")[0], "mark")) {
int id = Integer.parseInt(msgDescription.split(" ")[1]) - 1;
taskList[id].setDone();
taskList[id].printMark();
// Task.printHorizontalLine();
// System.out.println(" Nice! I've marked this task as done:");
// System.out.println(" [X] " + taskList[id].getDescription());
// Task.printHorizontalLine();
} else if (Objects.equals(msgDescription.split(" ")[0], "unmark")) {
int id = Integer.parseInt(msgDescription.split(" ")[1]) - 1;
taskList[id].setNotDone();
taskList[id].printUnmark();
// Task.printHorizontalLine();
// System.out.println(" OK, I've marked this task as not done yet:");
// System.out.println(" [] " + taskList[id].getDescription());
// Task.printHorizontalLine();
} else if (Objects.equals(msgDescription.split(" ")[0], "todo")) {
String description = msgDescription.replaceFirst("todo ", "");
taskList[Todo.getTotalNumberOfTask()] = new Todo(description);
int id = Todo.getTotalNumberOfTask() - 1;
taskList[id].printUpdatedTask();
} else if (Objects.equals(msgDescription.split(" ")[0], "deadline")) {
String[] DescriptionBy = msgDescription.replaceFirst("deadline ", "").split(" /by ");
String description = DescriptionBy[0];
String by = DescriptionBy[1];
taskList[Deadline.getTotalNumberOfTask()] = new Deadline(description, by);
int id = Task.getTotalNumberOfTask() - 1;
taskList[id].printUpdatedTask();
} else if (Objects.equals(msgDescription.split(" ")[0], "event")) {
String[] DescriptionAt = msgDescription.replaceFirst("event ", "").split(" /at ");
String description = DescriptionAt[0];
String at = DescriptionAt[1];
taskList[Event.getTotalNumberOfTask()] = new Event(description, at);
int id = Task.getTotalNumberOfTask() - 1;
taskList[id].printUpdatedTask();
} else {
// taskList[Task.getTotalNumberOfTask()] = new Task(msgDescription);
// System.out.println(" ____________________________________________________________");
// System.out.println(" added: " + msgDescription);
// System.out.println(" ____________________________________________________________");
taskList[Task.getTotalNumberOfTask()] = new Task(msgDescription);
int id = Task.getTotalNumberOfTask() - 1;
taskList[id].printUpdatedTask();
}
}
}
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 (Subject Only)
possible problems in commit ec8f9d9
:
Update printUpdatedTask, derived classes of Task, which is Todo, Deadline and Event
- Longer than 72 characters
possible problems in commit fd5d0f9
:
Updated SSH Key and save changes back to Lv5
- Not in imperative mood (?)
Suggestion: Follow the given conventions for Git commit messages for future commits (no need to modify past commit messages).
Aspect: Binary files in repo
Suggestion: Avoid committing binary files (e.g., *.class
, *.jar
, *.exe
) or third-party library files in to the repo.
โ 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 [email protected]
if you want to follow up on this post.