@beginner-web-developer 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/parser/Parser.java lines 38-131:
public String parse(String input) throws AliceException {
String[] result = input.split(" ", 2);
Command command = Command.stringToCommand(result[0]);
Task addedTask;
switch (command) {
case BYE:
return ui.showExitMessage();
case LIST:
return ui.getListedTasks(list.getSize(),
list.findTaskOfPriority(Priority.HIGH),
list.findTaskOfPriority(Priority.MEDIUM),
list.findTaskOfPriority(Priority.LOW));
case MARK:
String[] markParams = result[1].split(" ");
int markTaskNumber = checkValidTaskNumber(markParams[0]);
checkValidTaskInput(Command.MARK, markParams);
Task markTask = list.markTask(markTaskNumber, markParams[1]);
return ui.getHandleTaskMessage(markTask, "mark");
case UNMARK:
String[] unmarkParams = result[1].split(" ");
int unmarkTaskNumber = checkValidTaskNumber(unmarkParams[0]);
checkValidTaskInput(Command.UNMARK, unmarkParams);
Task unmarkTask = list.unmarkTask(unmarkTaskNumber, unmarkParams[1]);
return ui.getHandleTaskMessage(unmarkTask, "unmark");
case DELETE:
String[] deleteParams = result[1].split(" ");
int deleteTaskNumber = checkValidTaskNumber(deleteParams[0]);
checkValidTaskInput(Command.DELETE, deleteParams);
Task task = list.deleteTask(deleteTaskNumber, deleteParams[1]);
return ui.getHandleTaskMessage(task, "delete", list.getSize());
case TODO:
// result[1] contains description /p priority
checkValidTaskInput(Command.TODO, result);
String[] todoParams = result[1].split("/p");
addedTask = todoParams.length == 1
? list.addTask(Command.TODO, todoParams[0])
: list.addTask(Command.TODO, todoParams[0], todoParams[1].strip());
break;
case DEADLINE:
// result[1] contains description /by deadline /p priority
checkValidTaskInput(Command.DEADLINE, result);
String[] deadlineInfo = result[1].split("/by ");
checkValidTaskInput(Command.DEADLINE, deadlineInfo);
String[] deadlineParams = deadlineInfo[1].split("/p");
addedTask = deadlineParams.length == 1
? list.addTask(Command.DEADLINE, deadlineInfo[0], deadlineParams[0].strip())
: list.addTask(Command.DEADLINE, deadlineInfo[0], deadlineParams[0].strip(),
deadlineParams[1].strip());
break;
case EVENT:
// result[1] contains description /from from /to to /p priority
checkValidTaskInput(Command.EVENT, result);
String[] eventInfo = result[1].split("/from ");
checkValidTaskInput(Command.EVENT, eventInfo);
String[] times = eventInfo[1].split("/to ");
checkValidTaskInput(Command.EVENT, times);
String[] eventParams = times[1].split("/p");
addedTask = eventParams.length == 1
? list.addTask(Command.EVENT, eventInfo[0], times[0].strip(), eventParams[0].strip())
: list.addTask(Command.EVENT, eventInfo[0], times[0].strip(), eventParams[0].strip(),
eventParams[1].strip());
break;
case FIND:
return ui.getFilteredTasks(list.findTasks(result[1]));
case EXIT:
return "";
case PRIORITY:
String[] params = result[1].split(" ");
int taskNumber = checkValidTaskNumber(params[0]);
checkValidTaskInput(Command.PRIORITY, params);
Task updateTask = list.updatePriority(taskNumber, params[1].strip(), params[2].strip());
return ui.getHandleTaskMessage(updateTask, "priority", params[2].strip());
default:
throw new AliceException(input);
}
// check that only "todo", "deadline", and "event" prints the task message
assert result[0].equals("todo")
|| result[0].equals("deadline")
|| result[0].equals("event")
: "the command should be adding a task!";
// prints task messages for todos, deadlines, and events
return ui.getHandleTaskMessage(addedTask, "add", list.getSize());
}
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/MainWindow.java lines 42-44:
/**
* Initialise chatbot with welcome message.
*/
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
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.
@beginner-web-developer 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/parser/Parser.javalines38-131: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/MainWindow.javalines42-44: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
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.