@vvidday 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
Example from src/main/java/ekud/util/ParseResult.java lines 4-4:
public final boolean terminate;
Example from src/main/java/ekud/util/ParseResult.java lines 6-6:
public final boolean saveStorage;
Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)
Aspect: Brace Style
Example from src/main/java/ekud/util/Parser.java lines 59-60:
Suggestion: As specified by the coding standard, use egyptian style braces.
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/ekud/task/TaskList.java lines 151-198:
private Task parseSpecialTask(String description, TaskType type) throws EkudException {
Optional<Task> task = Optional.empty();
String[] parts = description.split(" ");
switch (type) {
case TODO:
if (parts.length < 2) {
throw new EkudException("Description of a TODO cannot be empty.");
}
task = Optional.of(new ToDo(String.join(" ", Arrays.copyOfRange(parts, 1, parts.length))));
break;
case DEADLINE:
// Fallthrough
case EVENT:
int idxOfSeparator = 0;
for (int i = 0; i < parts.length; i++) {
if (type == TaskType.EVENT && parts[i].equals("/at")) {
idxOfSeparator = i;
} else if (type == TaskType.DEADLINE && parts[i].equals("/by")) {
idxOfSeparator = i;
}
}
if (idxOfSeparator == 0) {
String separator = type == TaskType.EVENT ? "/at" : "/by";
throw new EkudException(
String.format("Invalid syntax. Use %s <task> %s <date/time>", type.toString(), separator));
} else if (idxOfSeparator == 1) {
throw new EkudException(String.format("Description of an %s cannot be empty.", type.toString()));
} else if (idxOfSeparator == parts.length - 1) {
throw new EkudException("Date/Time cannot be empty.");
}
String taskDesc = String.join(" ", Arrays.copyOfRange(parts, 1, idxOfSeparator));
String taskDueDate = String.join(" ", Arrays.copyOfRange(parts, idxOfSeparator + 1, parts.length));
if (type == TaskType.EVENT) {
task = Optional.of(new Event(taskDesc, taskDueDate));
} else {
task = Optional.of(new Deadline(taskDesc, taskDueDate));
}
break;
default:
throw new EkudException("Invalid task type.");
}
if (task.isEmpty()) {
throw new EkudException("Unexpected error.");
} else {
return task.get();
}
}
Example from src/main/java/ekud/util/Parser.java lines 29-63:
public ParseResult parseCommand(String command, TaskList taskList, NoteList noteList) throws EkudException {
String[] splitCommand = command.split(" ");
String firstWord = splitCommand[0];
if (command.equals("bye")) {
return new ParseResult(true, "Bye. Hope to see you again soon!", false);
} else if (command.equals("list")) {
return new ParseResult(false, taskList.printTasks(), false);
} else if (firstWord.equals("mark")) {
return new ParseResult(false, taskList.markAsDone(command), true);
} else if (firstWord.equals("unmark")) {
return new ParseResult(false, taskList.markAsUndone(command), true);
} else if (firstWord.equals("todo")) {
return new ParseResult(false, taskList.addTask(command, TaskType.TODO), true);
} else if (firstWord.equals("deadline")) {
return new ParseResult(false, taskList.addTask(command, TaskType.DEADLINE), true);
} else if (firstWord.equals("event")) {
return new ParseResult(false, taskList.addTask(command, TaskType.EVENT), true);
} else if (firstWord.equals("delete")) {
return new ParseResult(false, taskList.deleteTask(command), true);
} else if (firstWord.equals("find")) {
return new ParseResult(false, taskList.searchTasks(
String.join(" ", Arrays.copyOfRange(splitCommand, 1, splitCommand.length))), false);
} else if (firstWord.equals("note")) {
return new ParseResult(false,
noteList.addNote(String.join(" ", Arrays.copyOfRange(splitCommand, 1, splitCommand.length))),
true);
} else if (firstWord.equals("deletenote")) {
return new ParseResult(false, noteList.deleteNote(command), true);
} else if (firstWord.equals("listnote")) {
return new ParseResult(false, noteList.printNotes(), false);
}
else {
throw new EkudException("Invalid command.");
}
}
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/ekud/task/Task.java lines 50-55:
/**
* Get status icon of task.
*
* @return Character representing the status of the task (whether it is done or
* not)
*/
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)
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.
@vvidday 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
Example from
src/main/java/ekud/util/ParseResult.javalines4-4:Example from
src/main/java/ekud/util/ParseResult.javalines6-6:Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)
Aspect: Brace Style
Example from
src/main/java/ekud/util/Parser.javalines59-60:} else {Suggestion: As specified by the coding standard, use egyptian style braces.
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/ekud/task/TaskList.javalines151-198:Example from
src/main/java/ekud/util/Parser.javalines29-63: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/ekud/task/Task.javalines50-55: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)
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.