@jacobkwan We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the iP code further.
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
Example from src/main/java/duke/ui/Ui.java lines 50-50:
// String indentedInput = input.replaceAll("(?m)^", "\t");
Example from src/main/java/duke/ui/Ui.java lines 51-51:
// System.out.println("\t----------------------------------");
Example from src/main/java/duke/ui/Ui.java lines 53-53:
// System.out.println(indentedInput);
Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from src/main/java/duke/Parser.java lines 28-113:
public static Command parse(String fullCommand) throws DukeException {
fullCommand = fullCommand.strip();
String[] fullCommandArr = fullCommand.split(" ", 2);
String commandName = fullCommandArr[0].toUpperCase();
String restOfCommand = fullCommandArr.length > 1 ? fullCommandArr[1].strip() : "";
String description;
switch (commandName) {
case "TODO":
description = restOfCommand;
if (description.isBlank()) {
throw new DukeException("Description cannot be empty.");
}
return new AddCommand(TaskType.TODO, description, null);
case "DEADLINE":
try {
int index = restOfCommand.lastIndexOf("/by");
if (index == -1) {
throw new DukeException("To add a deadline, please specify '/by dd/mm/yy'.");
}
description = restOfCommand.substring(0, index);
if (description.isBlank()) {
throw new DukeException("Description cannot be empty.");
}
String deadlineString = restOfCommand.substring(index + 3).strip();
LocalDate deadline =
LocalDate.parse(deadlineString, DateTimeFormatter.ofPattern("dd/MM/yy"));
return new AddCommand(TaskType.DEADLINE, description, deadline);
} catch (DateTimeParseException e) {
throw new DukeException("To add a deadline, please specify '/by dd/mm/yy'.");
}
case "EVENT":
try {
int index = restOfCommand.lastIndexOf("/at");
if (index == -1) {
throw new DukeException("To add an event, please specify '/at dd/mm/yy'.");
}
description = restOfCommand.substring(0, index);
if (description.isBlank()) {
throw new DukeException("Description cannot be empty.");
}
String eventDateString = restOfCommand.substring(index + 3).strip();
LocalDate eventDate =
LocalDate.parse(eventDateString, DateTimeFormatter.ofPattern("dd/MM/yy"));
return new AddCommand(TaskType.EVENT, description, eventDate);
} catch (DateTimeParseException e) {
throw new DukeException("To add an event, please specify '/at dd/mm/yy'.");
}
case "FIND":
String keyword = restOfCommand;
if (keyword.isBlank()) {
throw new DukeException("Keyword cannot be empty.");
}
return new FindCommand(keyword);
case "DELETE":
try {
int index = Integer.valueOf(restOfCommand) - 1;
return new DeleteCommand(index);
} catch (NumberFormatException e) {
throw new DukeException("Task ID supplied is not a number.");
}
case "MARK":
try {
int index = Integer.valueOf(restOfCommand) - 1;
return new MarkCommand(index);
} catch (NumberFormatException e) {
throw new DukeException("Task ID supplied is not a number.");
}
case "UNMARK":
try {
int index = Integer.valueOf(restOfCommand) - 1;
return new UnmarkCommand(index);
} catch (NumberFormatException e) {
throw new DukeException("Task ID supplied is not a number.");
}
case "LIST":
return new ListCommand();
case "BYE":
return new ExitCommand();
default:
throw new DukeException("Invalid command!");
}
}
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
Example from src/main/java/duke/Duke.java lines 62-64:
/**
* Entry point of Duke application.
*/
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 👍
ℹ️ 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.
@jacobkwan We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the iP code further.
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
Example from
src/main/java/duke/ui/Ui.javalines50-50:// String indentedInput = input.replaceAll("(?m)^", "\t");Example from
src/main/java/duke/ui/Ui.javalines51-51:// System.out.println("\t----------------------------------");Example from
src/main/java/duke/ui/Ui.javalines53-53:// System.out.println(indentedInput);Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from
src/main/java/duke/Parser.javalines28-113: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
Example from
src/main/java/duke/Duke.javalines62-64: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 👍
ℹ️ 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.