@ngjunkang 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/baron/tasks/TaskManager.java lines 80-121:
public Task addTask(TaskType taskType, String commandArg) throws BaronException {
Task newTask;
if (taskType == TaskType.TODO) {
newTask = new ToDo(commandArg);
} else if (taskType == TaskType.DEADLINE) {
String[] commandArgs = commandArg.split(" /by ", 2);
if (commandArgs.length == 1) {
if (commandArgs[0].startsWith("/by")) {
throw new BaronException(Message.generateEmptyDescMessage(taskType));
}
throw new BaronException("Please specify a deadline by the /by keyword.");
} else if (commandArgs.length == 0) {
throw new BaronException(Message.generateEmptyDescMessage(taskType));
}
assert commandArgs.length == 2 : "commandArgs.length should be only up to 2";
LocalDateTime localDateTime = DateTimeUtil.getDateTime(commandArgs[1]);
newTask = new Deadline(commandArgs[0], localDateTime);
} else {
String[] commandArgs = commandArg.split(" /at ", 2);
if (commandArgs.length == 1) {
if (commandArgs[0].startsWith("/at")) {
throw new BaronException(Message.generateEmptyDescMessage(taskType));
}
throw new BaronException("Please specify a date by the /at keyword.");
} else if (commandArgs.length == 0) {
throw new BaronException(Message.generateEmptyDescMessage(taskType));
}
assert commandArgs.length == 2 : "commandArgs.length should be only up to 2";
LocalDateTime localDateTime = DateTimeUtil.getDateTime(commandArgs[1]);
newTask = new Event(commandArgs[0], localDateTime);
}
if (this.taskList.contains(newTask)) {
throw new BaronException(Message.generateDuplicateTaskMessage(taskType));
}
this.taskList.add(newTask);
this.previousTaskList = this.getAllTasks();
return newTask;
}
Example from src/main/java/baron/util/Storage.java lines 87-149:
private Task parseTaskString(String taskString) throws BaronException {
String[] taskStringArray = taskString.split(Storage.FILE_DELIMITER, 4);
if (taskStringArray.length < 3 || taskStringArray.length > 4) {
throw new BaronException(Message.MESSAGE_INVALID_FILE_FORMAT);
} else {
TaskType taskType;
boolean isDone;
String description = taskStringArray[2];
LocalDateTime additionalInfo = null;
switch (taskStringArray[0]) {
case "T":
taskType = TaskType.TODO;
break;
case "D":
taskType = TaskType.DEADLINE;
break;
case "E":
taskType = TaskType.EVENT;
break;
default:
throw new BaronException(Message.MESSAGE_INVALID_FILE_FORMAT);
}
if (taskStringArray[1].equals("1")) {
isDone = true;
} else if (taskStringArray[1].equals("0")) {
isDone = false;
} else {
throw new BaronException(Message.MESSAGE_INVALID_FILE_FORMAT);
}
if (taskStringArray.length == 4) {
additionalInfo = DateTimeUtil.getDateTime(taskStringArray[3]);
}
Task newTask;
if (taskType == TaskType.TODO) {
if (additionalInfo != null) {
throw new BaronException(Message.MESSAGE_INVALID_FILE_FORMAT);
} else {
newTask = new ToDo(description);
}
} else {
if (additionalInfo == null) {
throw new BaronException(Message.MESSAGE_INVALID_FILE_FORMAT);
} else {
if (taskType == TaskType.DEADLINE) {
newTask = new Deadline(description, additionalInfo);
} else {
newTask = new Event(description, additionalInfo);
}
}
}
if (isDone) {
newTask.mark();
}
return newTask;
}
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten 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/baron/message/Message.java lines 58-63:
/**
* Generate the message to warn that duplicate tasks have been detected.
*
* @param taskType the type of task.
* @return the message to warn that duplicate tasks have been detected.
*/
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 👍
ℹ️ The bot account @nus-se-bot 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.
@ngjunkang 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/baron/tasks/TaskManager.javalines80-121:Example from
src/main/java/baron/util/Storage.javalines87-149:Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten 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/baron/message/Message.javalines58-63: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 👍
ℹ️ The bot account @nus-se-bot 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.