@chiangqinkang 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
Example from src/main/java/Task/Event.java lines 75-76:
}
catch (ArrayIndexOutOfBoundsException | DateTimeParseException e) {
Suggestion: As specified by the coding standard, use egyptian style braces.
Aspect: Package Name Style
Example from src/main/java/CommandLine/Line.java lines 1-1:
Example from src/main/java/CommandLine/NotAGPT.java lines 1-1:
Example from src/main/java/CommandLine/Parser.java lines 1-1:
Suggestion: Follow the package naming convention specified by the coding standard.
Aspect: Class Name Style
No easy-to-detect issues 👍
Aspect: Dead Code
Example from src/main/java/GUI/Main.java lines 1-1:
Example from src/main/java/GUI/Main.java lines 3-3:
//import java.io.IOException;
Example from src/main/java/GUI/Main.java lines 5-5:
//import CommandLine.NotAGPT;
Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from src/main/java/CommandLine/Parser.java lines 20-84:
public static String parse(TaskList taskList, String inputTokens) {
Line line = new Line();
String[] parts = inputTokens.split(" ", 2);
String command = parts[0].toLowerCase();
switch(command) {
case "bye":
NotAGPTExit();
return "Goodbye";
case "list":
return taskList.list();
case "mark":
if (parts.length > 1) {
String idx = parts[1];
return taskList.markAsDone(idx);
} else {
return "Enter a task number";
}
case "unmark":
if (parts.length > 1) {
String idx = parts[1];
return taskList.markAsUndone(idx);
} else {
return "Enter a task number";
}
case "todo":
if (parts.length > 1) {
return taskList.add(parts[1], Task.TaskType.T);
} else {
return "Enter a name for the To Do Task";
}
case "deadline":
if (parts.length > 1) {
return taskList.add(parts[1], Task.TaskType.D);
} else {
return "Incomplete command. Enter a deadline";
}
case "event":
if (parts.length > 1) {
return taskList.add(parts[1], Task.TaskType.E);
} else {
return "Incomplete command. Enter a start and end time";
}
case "delete":
if (parts.length == 2) {
try {
int idx = parseInt(parts[1]);
return taskList.delete(idx);
} catch (NumberFormatException e) {
return "Enter a valid index to delete";
}
} else {
return "Enter a valid argument";
}
case "find":
if (parts.length == 2) {
String word = parts[1];
return taskList.find(word);
} else {
return "Enter a word";
}
default:
return "Unknown command, type help for a list of available commands";
}
}
Example from src/main/java/Task/TaskList.java lines 76-119:
private Task parseTask(String line) {
String[] parts = line.split(" \\| ");
for (String part : parts) {
assert !part.isEmpty() : "Error";
}
Task.TaskType taskType = Task.TaskType.valueOf(parts[0]);
boolean isDone = parts[1].equals("1");
String description = parts[2];
Task task;
list();
switch (taskType) {
case T:
task = ToDo.of(description, taskType);
this.taskList.add(task);
saveTasks();
break;
case D:
try {
task = Deadline.of(description + " /by " + parts[3], taskType);
this.taskList.add(task);
saveTasks();
} catch (TaskCreationException e) {
throw new IllegalArgumentException("Invalid task type: " + taskType);
}
break;
case E:
try {
task = Event.of(description + "/from " + parts[3] + " /to " + parts[4], taskType);
this.taskList.add(task);
saveTasks();
} catch (TaskCreationException e) {
System.out.println("Error occurred while parsing task");
throw new IllegalArgumentException("Invalid task type: " + taskType);
}
break;
default:
throw new IllegalArgumentException("Invalid task type: " + taskType);
}
if (isDone) {
task.markAsDone();
}
return task;
}
Example from src/main/java/Task/TaskList.java lines 129-173:
public String add(String s, Task.TaskType taskType) {
StringBuilder response = new StringBuilder();
try {
Task newTask;
switch (taskType) {
case T:
newTask = ToDo.of(s, taskType);
break;
case D:
newTask = Deadline.of(s, taskType);
break;
case E:
newTask = Event.of(s, taskType);
break;
default:
throw new IllegalArgumentException("Invalid task type");
}
if (isDuplicate(newTask)) {
return "That task is a duplicate, unable to add task";
}
this.taskList.add(newTask);
this.taskListLength += 1;
response.append("Got it. I've added this task:\n")
.append("[")
.append(newTask.getTaskTypeAsString())
.append("][ ] ")
.append(newTask.getTaskName())
.append("\n");
if (this.taskListLength == 1) {
response.append("Now you have 1 task in the list.\n");
} else {
response.append("Now you have ")
.append(this.taskListLength)
.append(" tasks in the list.\n");
}
} catch (TaskCreationException e) {
response.append(e.getMessage())
.append("\n");
}
return response.toString();
}
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
No easy-to-detect issues 👍
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.
@chiangqinkang 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
Example from
src/main/java/Task/Event.javalines75-76:} catch (ArrayIndexOutOfBoundsException | DateTimeParseException e) {Suggestion: As specified by the coding standard, use egyptian style braces.
Aspect: Package Name Style
Example from
src/main/java/CommandLine/Line.javalines1-1:Example from
src/main/java/CommandLine/NotAGPT.javalines1-1:Example from
src/main/java/CommandLine/Parser.javalines1-1:Suggestion: Follow the package naming convention specified by the coding standard.
Aspect: Class Name Style
No easy-to-detect issues 👍
Aspect: Dead Code
Example from
src/main/java/GUI/Main.javalines1-1://package GUI;Example from
src/main/java/GUI/Main.javalines3-3://import java.io.IOException;Example from
src/main/java/GUI/Main.javalines5-5://import CommandLine.NotAGPT;Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from
src/main/java/CommandLine/Parser.javalines20-84:Example from
src/main/java/Task/TaskList.javalines76-119:Example from
src/main/java/Task/TaskList.javalines129-173: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
No easy-to-detect issues 👍
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.