@WeeJean 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/weewee/parser/CommandParser.java lines 74-211:
public static String parseAndExecute(String input, TaskList tasks, Ui ui) throws WeeweeException {
Command cmd = getCommand(input);
switch (cmd) {
case LIST:
return ui.showList(tasks);
case MARK:
String[] marksplit = input.split(" ");
int marknumber = Integer.parseInt(marksplit[1]);
if (marksplit.length != 2 || marknumber < 1 || marknumber > tasks.size()) {
throw new WeeweeException(ui.showIndexError());
}
tasks.get(marknumber - 1).setDone();
return ui.showMark(tasks.get(marknumber - 1));
case UNMARK:
String[] unmarksplit = input.split(" ");
int unmarknumber = Integer.parseInt(unmarksplit[1]);
if (unmarksplit.length != 2 || unmarknumber < 1 || unmarknumber > tasks.size()) {
throw new WeeweeException(ui.showIndexError());
}
tasks.get(unmarknumber - 1).setUndone();
return ui.showUnmark(tasks.get(unmarknumber - 1));
case DELETE:
String[] deletesplit = input.split(" ");
int deletenumber = Integer.parseInt(deletesplit[1]);
if (deletesplit.length != 2 || deletenumber < 1 || deletenumber > tasks.size()) {
throw new WeeweeException(ui.showIndexError());
}
Task deleted = tasks.remove(deletenumber - 1);
return ui.showDelete(deleted, tasks);
case TODO:
String[] todosplit = input.split("todo ");
if (todosplit.length < 2) {
throw new WeeweeException(ui.showTodoError());
}
Task todo = new ToDo(todosplit[1].trim());
tasks.add(todo);
return ui.showTodo(todo, tasks);
case DEADLINE:
String[] deadlinesplit = input.split("deadline | /by ");
if (deadlinesplit.length < 3) {
throw new WeeweeException(ui.showDeadlineError());
}
Task deadline = new Deadline(deadlinesplit[1].trim(), deadlinesplit[2].trim());
tasks.add(deadline);
return ui.showDeadline(deadline, tasks);
case EVENT:
String[] eventsplit = input.split("event | /from | /to ");
if (eventsplit.length < 4) {
throw new WeeweeException(ui.showEventError());
}
Task event = new Event(eventsplit[1].trim(), eventsplit[2].trim(), eventsplit[3].trim());
tasks.add(event);
return ui.showEvent(event, tasks);
case FIND:
String[] findsplit = input.split("\\s+");
if (findsplit.length < 2) {
throw new WeeweeException(ui.showFindError());
}
TaskList matchingTasks = new TaskList(new ArrayList<>());
for (int i = 0; i < tasks.size(); i++) {
boolean isMatching = true;
for (int j = 1; j < findsplit.length; j++) {
if (!tasks.get(i).getTaskName().matches(".*\\b" + findsplit[j].toLowerCase() + "\\b.*")) {
isMatching = false;
break;
}
}
if (isMatching) {
matchingTasks.add(tasks.get(i));
}
}
return ui.showFind(matchingTasks);
case SORT:
String[] sortsplit = input.split("\\s+", 2);
if (sortsplit.length < 2) {
throw new WeeweeException(ui.showSortError());
}
String criteria = sortsplit[1].toLowerCase();
TaskList sortedTasks;
switch (criteria) {
case "deadline":
sortedTasks = new TaskList(
tasks.getAll().stream()
.filter(t -> t instanceof Deadline)
.sorted((t1, t2) -> ((Deadline) t1).getRawDate().compareTo(((Deadline) t2)
.getRawDate()))
.collect(java.util.stream.Collectors.toCollection(ArrayList::new))
);
break;
case "event start":
sortedTasks = new TaskList(
tasks.getAll().stream()
.filter(t -> t instanceof Event)
.sorted((t1, t2) -> ((Event) t1).getRawStart().compareTo(((Event) t2).getRawStart()))
.collect(java.util.stream.Collectors.toCollection(ArrayList::new))
);
break;
case "event end":
sortedTasks = new TaskList(
tasks.getAll().stream()
.filter(t -> t instanceof Event)
.sorted((t1, t2) -> ((Event) t1).getRawEnd().compareTo(((Event) t2).getRawEnd()))
.collect(java.util.stream.Collectors.toCollection(ArrayList::new))
);
break;
default:
throw new WeeweeException(ui.showSortError());
}
return ui.showList(sortedTasks);
default:
throw new WeeweeException("Sorry, I don't understand what that means </3\n");
}
}
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.
@WeeJean 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/weewee/parser/CommandParser.javalines74-211: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.