@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
Example from src/main/java/weewee/parser/CommandParser.java lines 128-128:
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
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 53-190:
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 matching = true;
for (int j = 1; j < findsplit.length; j++) {
if (!tasks.get(i).getTaskName().matches(".*\\b" + findsplit[j].toLowerCase() + "\\b.*")) {
matching = false;
break;
}
}
if (matching) {
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
possible problems in commit b8a9fae:
Add assertions
Introduce assert statements in core classes (DialogBox, MainWindow)
to document critical assumptions and catch unexpected states during
development and debugging.
- DialogBox: assert command type is not null before applying style changes.
- MainWindow: assert Weewee instance are properly
initialized before processing.
These assertions serve as internal contracts for developers, helping
to surface logical errors early. They do not replace exception handling
for user-facing errors.
- body not wrapped at 72 characters: e.g.,
- DialogBox: assert command type is not null before applying style changes.
Suggestion: Follow the given conventions for Git commit messages for future commits (do not modify past commit messages as doing so will change the commit timestamp that we used to detect your commit timings).
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
Example from
src/main/java/weewee/parser/CommandParser.javalines128-128: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
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.javalines53-190: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
possible problems in commit
b8a9fae:- DialogBox: assert command type is not null before applying style changes.Suggestion: Follow the given conventions for Git commit messages for future commits (do not modify past commit messages as doing so will change the commit timestamp that we used to detect your commit timings).
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.