@brenda77777 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/candy/TaskList.java lines 161-230:
public String formatSortedForDisplay() {
if (tasks.isEmpty()) {
return "Your task list is empty.";
}
ArrayList<Deadline> urgent = new ArrayList<>();
ArrayList<Deadline> completedDeadlines = new ArrayList<>();
ArrayList<Todo> todos = new ArrayList<>();
ArrayList<Event> events = new ArrayList<>();
// Separate tasks into groups
for (Task task : tasks) {
if (task instanceof Deadline) {
Deadline deadline = (Deadline) task;
if (!deadline.isDone()) {
urgent.add(deadline);
} else {
completedDeadlines.add(deadline);
}
} else if (task instanceof Todo) {
todos.add((Todo) task);
} else if (task instanceof Event) {
events.add((Event) task);
}
}
// Sort deadlines by date
urgent.sort(Comparator.comparing(Deadline::getByTime));
completedDeadlines.sort(Comparator.comparing(Deadline::getByTime));
StringBuilder sb = new StringBuilder();
sb.append(" ~~Incomplete Urgent Tasks~~ \n");
if (urgent.isEmpty()) {
sb.append("None\n");
} else {
for (Deadline deadline : urgent) {
sb.append("- ").append(deadline).append("\n");
}
}
sb.append("\n ~~Completed Deadlines~~ \n");
if (completedDeadlines.isEmpty()) {
sb.append("None\n");
} else {
for (Deadline deadline : completedDeadlines) {
sb.append("- ").append(deadline).append("\n");
}
}
sb.append("\n ~~Todos~~ \n");
if (todos.isEmpty()) {
sb.append("None\n");
} else {
for (Todo todo : todos) {
sb.append("- ").append(todo).append("\n");
}
}
sb.append("\n ~~Events~~ \n");
if (events.isEmpty()) {
sb.append("None\n");
} else {
for (Event event : events) {
sb.append("- ").append(event).append("\n");
}
}
return sb.toString();
}
Example from src/main/java/candy/ParsedCommand.java lines 56-119:
public String execute(TaskList tasks, Ui ui, Storage storage) throws CandyException {
switch (type) {
case LIST:
return ui.getListText(tasks);
case TODO: {
Task task = new Todo(description);
tasks.add(task);
storage.saveLines(tasks.toLines());
return ui.getAddText(task, tasks.size());
}
case DEADLINE: {
LocalDate date = Parser.parseDate(byDate);
Task task = new Deadline(description, date);
tasks.add(task);
storage.saveLines(tasks.toLines());
return ui.getAddText(task, tasks.size());
}
case EVENT: {
Task task = new Event(description, fromTime, toTime);
tasks.add(task);
storage.saveLines(tasks.toLines());
return ui.getAddText(task, tasks.size());
}
case MARK: {
tasks.mark(index);
storage.saveLines(tasks.toLines());
return ui.getMarkText(tasks.get(index));
}
case UNMARK: {
tasks.unmark(index);
storage.saveLines(tasks.toLines());
return ui.getUnmarkText(tasks.get(index));
}
case DELETE: {
Task removed = tasks.remove(index);
storage.saveLines(tasks.toLines());
return ui.getDeleteText(removed, tasks.size());
}
case FIND: {
TaskList matches = tasks.find(keyword);
return ui.getFindText(keyword, matches);
}
case SORT:
return tasks.formatSortedForDisplay();
case HELP:
return ui.getHelpText();
case BYE:
storage.saveLines(tasks.toLines());
return ui.getByeText();
default:
throw new CandyException("Unknown command. Type 'help' to see available commands.");
}
}
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
Suggestion: Avoid committing binary files (e.g., *.class, *.jar, *.exe) or third-party library files in to the repo.
❗ 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@nus.edu.sg if you want to follow up on this post.
@brenda77777 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/candy/TaskList.javalines161-230:Example from
src/main/java/candy/ParsedCommand.javalines56-119: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
src/main/java/candy/Event.classsrc/main/java/candy/CandyException.classsrc/main/java/candy/Task.classSuggestion: Avoid committing binary files (e.g.,
*.class,*.jar,*.exe) or third-party library files in to the repo.❗ 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@nus.edu.sgif you want to follow up on this post.