@Taoseeker 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
No easy-to-detect issues 👍
Aspect: Method Length
Example from src/main/java/neochat/task/Parser.java lines 36-95:
public String parseCommand(String input) {
if (input == null || input.trim().isEmpty()) {
throw new IllegalArgumentException("The input is empty");
}
String s = ""; // a dummy variable to hold returned string
String[] tokens = input.split("\\s+", 2);
String commandType = tokens[0].toLowerCase();
String remainingInput = (tokens.length > 1) ? tokens[1] : "";
try {
switch (commandType) {
case "todo":
s = parseTodo(remainingInput);
break;
case "deadline":
s = parseDeadline(remainingInput);
break;
case "event":
s = parseEvent(remainingInput);
break;
case "bye":
taskList.saveTasks();
s = "bye";
break;
case "list":
s = taskList.printList();
break;
case "mark":
s = taskList.markAsDone(remainingInput);
break;
case "unmark":
s = taskList.markAsNotDone(remainingInput);
break;
case "delete":
s = taskList.delete(remainingInput);
break;
case "archive":
s = taskList.archive(remainingInput);
break;
case "loadarchive":
taskList.loadArchivedTasks();
s = "successfully loaded archived tasks!";
break;
case "help":
s = printCommandList();
break;
case "find":
s = taskList.findTasks(remainingInput);
break;
default:
s = "Unknown command type" + commandType + "\n"
+ "key in 'help' for more information.'";
}
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
assert s != null : "parseCommand() should not return null";
assert !s.isEmpty() : "parseCommand() should not return empty string";
return s;
}
Example from src/main/java/neochat/task/tasklist/TaskList.java lines 129-179:
private Task parseTask(String line) {
String[] parts = line.split(" \\| ");
if (parts.length < 3) {
return null;
}
String type = parts[0];
boolean isDone = parts[1].equals("1");
String description = parts[2];
try {
switch (type) {
case "T":
Todo todo = new Todo(description);
if (isDone) {
todo.markAsDone();
}
return todo;
case "D":
if (parts.length < 4) {
return null;
}
LocalDateTime by = parseDateTime(parts[3].trim());
Deadline deadline = new Deadline(description, by);
if (isDone) {
deadline.markAsDone();
}
return deadline;
case "E":
if (parts.length < 5) {
return null;
}
LocalDateTime from = parseDateTime(parts[3].trim());
LocalDateTime to = parseDateTime(parts[4].trim());
Event event = new Event(description, from, to);
if (isDone) {
event.markAsDone();
}
return event;
default:
return null;
}
} catch (EmptyTaskDescriptionException e) {
// Should not reach this line: anything in the saved file should have a description as this exception is
// already handled when the user set the task
System.out.println("Wrong format of task description in the saved list, please check if the saved list is "
+ "edited accidentally");
return null;
}
}
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
No easy-to-detect issues 👍
Aspect: Binary files in repo
No easy-to-detect issues 👍
❗ 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 cs2103@comp.nus.edu.sg if you want to follow up on this post.
@Taoseeker 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
No easy-to-detect issues 👍
Aspect: Method Length
Example from
src/main/java/neochat/task/Parser.javalines36-95:Example from
src/main/java/neochat/task/tasklist/TaskList.javalines129-179: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
No easy-to-detect issues 👍
Aspect: Binary files in repo
No easy-to-detect issues 👍
❗ 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
cs2103@comp.nus.edu.sgif you want to follow up on this post.