-
Notifications
You must be signed in to change notification settings - Fork 0
Description
@Shangda777 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
No easy-to-detect issues 👍
Aspect: Method Length
Example from src/main/java/richal/command/Parser.java lines 19-112:
public static String parseAndGetResponse(String input, TaskList taskList, Ui ui, Storage storage) throws DukeException {
if (input.equals("bye")) {
return ui.getGoodbyeMessage();
}
if (input.equals("list")) {
return ui.getTaskListMessage(taskList);
}
if (input.startsWith("find ")) {
String keyword = input.substring(5).trim();
if (keyword.isEmpty()) {
throw new DukeException("Please provide a keyword to search for.");
}
List<Task> matching = taskList.findTasks(keyword);
return ui.getMatchingTasksMessage(matching);
}
if (input.startsWith("mark ")) {
int index = parseIndex(input.substring(5).trim(), taskList.getSize());
taskList.getTask(index).markDone();
saveToStorage(taskList, storage, ui);
return ui.getTaskMarkedMessage(taskList.getTask(index));
}
if (input.startsWith("unmark ")) {
int index = parseIndex(input.substring(7).trim(), taskList.getSize());
taskList.getTask(index).markUndone();
saveToStorage(taskList, storage, ui);
return ui.getTaskUnmarkedMessage(taskList.getTask(index));
}
if (input.startsWith("delete ")) {
int index = parseIndex(input.substring(7).trim(), taskList.getSize());
Task deletedTask = taskList.getTask(index);
taskList.deleteTask(index);
saveToStorage(taskList, storage, ui);
return ui.getTaskDeletedMessage(deletedTask, taskList.getSize());
}
if (input.startsWith("todo")) {
String desc = input.length() > 4 ? input.substring(5).trim() : "";
if (desc.isEmpty()) {
throw new DukeException("The description of a todo cannot be empty.");
}
Task task = new Todo(desc);
taskList.addTask(task);
saveToStorage(taskList, storage, ui);
return ui.getTaskAddedMessage(task, taskList.getSize());
}
if (input.startsWith("deadline")) {
String[] parts = input.length() > 8 ? input.substring(8).trim().split("/by") : new String[0];
if (parts.length != 2) {
throw new DukeException("The description of a deadline must contain a /by date.");
}
try {
Task task = new Deadline(parts[0].trim(), parts[1].trim());
taskList.addTask(task);
saveToStorage(taskList, storage, ui);
return ui.getTaskAddedMessage(task, taskList.getSize());
} catch (Exception e) {
throw new DukeException("Invalid date/time format. Supported formats:\n"
+ " - 2/12/2019 1800 or 2/12/2019 18:00\n"
+ " - 2019-12-02 1800 or 2019-12-02 18:00\n"
+ " - 2/12/2019 (defaults to 00:00)");
}
}
if (input.startsWith("event")) {
String[] parts = input.length() > 6 ? input.substring(6).trim().split("/from") : new String[0];
if (parts.length != 2) {
throw new DukeException("The description of an event must contain a /from date.");
}
String[] toParts = parts[1].length() > 3 ? parts[1].trim().split("/to") : new String[0];
if (toParts.length != 2) {
throw new DukeException("The description of an event must contain a /to date.");
}
try {
Task task = new Event(parts[0].trim(), toParts[0].trim(), toParts[1].trim());
taskList.addTask(task);
saveToStorage(taskList, storage, ui);
return ui.getTaskAddedMessage(task, taskList.getSize());
} catch (Exception e) {
throw new DukeException("Invalid date/time format. Supported formats:\n"
+ " - 2/12/2019 1800 or 2/12/2019 18:00\n"
+ " - 2019-12-02 1800 or 2019-12-02 18:00\n"
+ " - 2/12/2019 (defaults to 00:00)");
}
}
throw new DukeException("I'm sorry, but I don't know what that means :-(");
}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 👍
ℹ️ 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.