@jhwan0707 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/Johan.java lines 10-10:
// Task[] tasks = new Task[100];
Example from src/main/java/Johan.java lines 12-12:
Example from src/main/java/Johan.java lines 52-52:
// tasks[taskCount++] = new Todo(description);
Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from src/main/java/Johan.java lines 5-99:
public static void main(String[] args) {
String input;
Scanner scanner = new Scanner(System.in);
System.out.println("Hello! I'm Johan");
System.out.println("What can I do for you?");
// Task[] tasks = new Task[100];
ArrayList<Task> tasks = new ArrayList<>();
// int taskCount = 0;
while (true) {
input = scanner.nextLine().toLowerCase().trim();
String[] words = input.split("");
if (input.equals("bye")) {
break;
} else if (input.equals("list")) {
System.out.println("Here are the tasks in your list:");
for (int i = 0; i < tasks.size(); i++) {
System.out.println((i + 1) + "." + tasks.get(i).toString());
}
} else if (input.startsWith("mark ")) {
String taskID = input.substring(5);
int id = Integer.parseInt(taskID);
if (id > 0 && id <= tasks.size()) {
tasks.get(id - 1).markAsDone();
System.out.println("Nice! I've marked this task as done:");
System.out.println(tasks.get(id - 1).toString());
}
} else if (input.startsWith("unmark ")) {
String taskID = input.substring(7);
int id = Integer.parseInt(taskID);
if (id > 0 && id <= tasks.size()) {
tasks.get(id - 1).markAsNotDone();
System.out.println("OK, I've marked this task as not done yet:");
System.out.println(tasks.get(id - 1).toString());
}
} else if (input.startsWith("todo")) {
String description = input.substring(4).trim();
if (description.isEmpty()) {
System.out.println("____________________________________________________________");
System.out.println(" OOPS!!! The description of a todo cannot be empty.");
System.out.println("____________________________________________________________");
} else {
tasks.add(new Todo(description));
System.out.println("Got it. I've added this task:");
System.out.println(tasks.get(tasks.size() - 1).toString());
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
}
// tasks[taskCount++] = new Todo(description);
// System.out.println("Got it. I've added this task:");
// System.out.println(tasks[taskCount - 1].toString());
// System.out.println("Now you have " + taskCount + " tasks in the list.");
} else if (input.startsWith("deadline")) {
int byIndex = input.indexOf("/by");
String description = input.substring(9, byIndex).trim();
String by = input.substring(byIndex + 4);
by = by.substring(0, 1).toUpperCase() + by.substring(1);
tasks.add(new Deadline(description, by));
System.out.println("Got it. I've added this task:");
System.out.println(tasks.get(tasks.size() - 1).toString());
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
} else if (input.startsWith("event")) {
int fromIndex = input.indexOf("/from");
int toIndex = input.indexOf("/to");
String description = input.substring(6, fromIndex).trim();
String startDate = input.substring(fromIndex + 6, toIndex);
startDate = startDate.substring(0, 1).toUpperCase() + startDate.substring(1);
String endDate = input.substring(toIndex + 3).trim();
endDate = endDate.substring(0, 1).toUpperCase() + endDate.substring(1);
tasks.add(new Event(description, startDate, endDate));
System.out.println("Got it. I've added this task:");
System.out.println(tasks.get(tasks.size() - 1).toString());
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
} else if (input.startsWith("delete")) {
String taskID = input.substring(7);
int id = Integer.parseInt(taskID);
if (id > 0 && id <= tasks.size()) {
Task removedTask = tasks.remove(id - 1);
System.out.println("____________________________________________________________");
System.out.println("Noted. I've removed this task:");
System.out.println(removedTask.toString());
System.out.println("Now you have " + tasks.size() + " tasks in the list.");
System.out.println("____________________________________________________________");
} else {
System.out.println("____________________________________________________________");
System.out.println(" OOPS!!! The task ID is invalid.");
System.out.println("____________________________________________________________");
}
} else {
System.out.println("____________________________________________________________");
System.out.println(" OOPS!!! I'm sorry, but I don't know what that means :-(");
System.out.println("____________________________________________________________");
}
}
System.out.println("Bye. Hope to see you again soon!");
}
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 e30a5d9:
possible problems in commit 52c7599:
Automated Text UI Testing
- Not in imperative mood (?)
possible problems in commit 80f4f23:
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.
@jhwan0707 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/Johan.javalines10-10:// Task[] tasks = new Task[100];Example from
src/main/java/Johan.javalines12-12:// int taskCount = 0;Example from
src/main/java/Johan.javalines52-52:// tasks[taskCount++] = new Todo(description);Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from
src/main/java/Johan.javalines5-99: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
e30a5d9:possible problems in commit
52c7599:possible problems in commit
80f4f23: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.