@clarence-chew 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/duke/ParsedDateTime.java lines 220-220:
Example from src/main/java/duke/ParsedDateTime.java lines 239-239:
boolean invalidMinute = minute < 0 || minute >= MINUTES_PER_HOUR;
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/duke/Parser.java lines 86-119:
public static ArrayList<CommandMatcher> addTaskCommands(ArrayList<CommandMatcher> commands) {
assert commands != null;
commands.add(new PrefixCommandMatcher("deadline", (str, map) -> {
assert str != null;
assert map != null;
Task task = new Deadline(str, map.getOrDefault("by", "[unknown]"));
TaskList.getTaskList().add(task);
return new DukeResponse(
"Good luck with the deadline, here's the task:",
task.toString());
}));
commands.add(new PrefixCommandMatcher("todo", (str, map) -> {
assert str != null;
assert map != null;
Task task = new ToDo(str);
TaskList.getTaskList().add(task);
return new DukeResponse(
"I've recorded this thing you need to do:",
task.toString());
}));
commands.add(new PrefixCommandMatcher("event", (str, map) -> {
assert str != null;
assert map != null;
Task task = new Event(str, map.getOrDefault("at", "[unknown]"));
TaskList.getTaskList().add(task);
return new DukeResponse(
"That's going to happen at some time later:",
task.toString());
}));
return commands;
}
Example from src/main/java/duke/Parser.java lines 126-188:
public static ArrayList<CommandMatcher> addTaskModificationCommands(ArrayList<CommandMatcher> commands) {
assert commands != null;
commands.add(PrefixCommandMatcher.of("mark", (str, map) -> {
assert str != null;
assert map != null;
Task task = TaskList.getTask(str);
task.markAsDone();
return new DukeResponse(
"Marked your task as done:",
task.toString());
}));
commands.add(PrefixCommandMatcher.of("unmark", (str, map) -> {
assert str != null;
assert map != null;
Task task = TaskList.getTask(str);
task.markAsNotDone();
return new DukeResponse(
"Aw... it's not done yet:",
task.toString());
}));
commands.add(PrefixCommandMatcher.of("delete", (str, map) -> {
assert str != null;
assert map != null;
Task task = TaskList.getTask(str);
TaskList.getTaskList().remove(task);
return new DukeResponse(
"It seems you didn't need this task anymore, so I removed it:",
task.toString(),
String.format("You have %d tasks left.", TaskList.getTaskList().size()));
}));
commands.add(PrefixCommandMatcher.of("reschedule", (str, map) -> {
assert str != null;
assert map != null;
Task task = TaskList.getTask(str);
if (task instanceof ToDo) {
return new DukeResponse("That's a todo, it doesn't have a date.");
}
Task newTask;
if (task instanceof Event) {
if (!map.containsKey("at")) {
return new DukeResponse("Do specify /at for events.");
}
newTask = new Event(task.getDescription(), map.get("at"), task.isTaskDone());
} else if (task instanceof Deadline) {
if (!map.containsKey("by")) {
return new DukeResponse("Do specify /by for deadlines.");
}
newTask = new Deadline(task.getDescription(), map.get("by"), task.isTaskDone());
} else {
return new DukeResponse("This is a strange task - I don't recognise it.");
}
List<Task> tasks = TaskList.getTaskList();
tasks.set(tasks.indexOf(task), newTask);
return new DukeResponse(
"I have rescheduled your task!",
newTask.toString());
}));
return commands;
}
Example from src/main/java/duke/Parser.java lines 220-263:
public static ArrayList<CommandMatcher> addNoteCommands(ArrayList<CommandMatcher> commands) {
assert commands != null;
commands.add(new CommandMatcher(str -> str.equals("list notes"), (str) -> {
assert str != null;
List<Note> notes = NoteList.getNoteList();
return new DukeResponse(
listObjects("Here, your notes:", notes));
}));
commands.add(new PrefixCommandMatcher("find notes", (str, map) -> {
assert str != null;
assert map != null;
List<Pair<Integer, Note>> notes = NoteList.filterNotes(str);
return new DukeResponse(
listNumberedObjects("These notes match your query:", notes));
}));
commands.add(PrefixCommandMatcher.of("view note", (str, map) -> {
assert str != null;
assert map != null;
Note note = NoteList.getNote(str);
return new DukeResponse("Here's the note:", note.getTitle(), note.getContent());
}));
commands.add(PrefixCommandMatcher.of("delete note", (str, map) -> {
assert str != null;
assert map != null;
Note note = NoteList.getNote(str);
NoteList.getNoteList().remove(note);
return new DukeResponse(
"I removed this note:",
note.toString());
}));
commands.add(PrefixCommandMatcher.of("note", (str, map) -> {
assert str != null;
assert map != null;
Note note = new Note(str, map.getOrDefault("content", "[EMPTY]"));
NoteList.getNoteList().add(note);
return new DukeResponse(String.format("Added your note about %s.", str));
}));
return 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
Suggestion: Consider breaking large classes into smaller ones, if appropriate. A long class is a sign that perhaps it is dong 'too much'.
Aspect: Header Comments
Example from src/main/java/duke/gui/MainWindow.java lines 53-57:
/**
* Get the writer that writes out GUI interactions.
*
* @return The writer that writes out GUI interactions.
*/
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.
@clarence-chew 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/duke/ParsedDateTime.javalines220-220:Example from
src/main/java/duke/ParsedDateTime.javalines239-239: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/duke/Parser.javalines86-119:Example from
src/main/java/duke/Parser.javalines126-188:Example from
src/main/java/duke/Parser.javalines220-263: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
src\main\java\duke\ParsedDateTime.java(722 lines)Suggestion: Consider breaking large classes into smaller ones, if appropriate. A long class is a sign that perhaps it is dong 'too much'.
Aspect: Header Comments
Example from
src/main/java/duke/gui/MainWindow.javalines53-57: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.