-
Notifications
You must be signed in to change notification settings - Fork 0
Description
@VikramGoyal23 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/tyler/command/AddCommand.java lines 33-102:
public TaskList execute(TaskList tasks, Ui ui, Storage storage) {
try {
if (tokens[0].equalsIgnoreCase("todo")) {
ToDo toDo = new ToDo(tokens[1]);
assert toDo.getCategory().equals("T");
boolean noDuplicates = true;
for (Task t: tasks) {
if (toDo.equals(t)){
noDuplicates = false;
break;
}
}
if (noDuplicates) {
tasks.addToList(toDo, ui);
} else {
ui.showMessage("\t !!This task already exists!!");
}
} else if (tokens[0].equalsIgnoreCase("deadline")) {
if (!tokens[1].contains("/by") || tokens[1].split("/by ")[1].isBlank()) {
throw new IllegalArgumentException("\t !!Deadline must include a 'by' time!!");
}
Deadline deadline = new Deadline(
tokens[1].split(" /by")[0], tokens[1].split("/by ")[1]);
assert deadline.getCategory().equals("D");
boolean noDuplicates = true;
for (Task d: tasks) {
if (deadline.equals(d)){
noDuplicates = false;
break;
}
}
if (noDuplicates) {
tasks.addToList(deadline, ui);
} else {
ui.showMessage("\t !!This task already exists!!");
}
} else if (tokens[0].equalsIgnoreCase("event")) {
if (!tokens[1].contains("/from") || !tokens[1].contains("/to")
|| tokens[1].split("/from ")[1].split(" /to")[0].isBlank()
|| tokens[1].split("/to ")[1].isBlank()
) {
throw new IllegalArgumentException(
"\t !!Event must include a 'from' time and 'to' time!!");
}
Event event = new Event(tokens[1].split(" /from")[0],
tokens[1].split("/from ")[1].split(" /to")[0],
tokens[1].split("/to ")[1]);
assert event.getCategory().equals("E");
boolean noDuplicates = true;
for (Task e: tasks) {
if (event.equals(e)){
noDuplicates = false;
break;
}
}
if (noDuplicates) {
tasks.addToList(event, ui);
} else {
ui.showMessage("\t !!This task already exists!!");
}
}
} catch (ArrayIndexOutOfBoundsException e) {
ui.showMessage("\t !!Please provide the correct number of arguments!!");
} catch (IllegalArgumentException e) {
ui.showMessage(e.getMessage());
} catch (DateTimeParseException e) {
ui.showMessage("\t !!Please enter the date in YYYY-MM-DD format!!");
}
return tasks;
}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.