@vishandi 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
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/duke/Duke.java lines 101-185:
public String processUserInput(String userInput) {
assert userInput != null;
String[] userInputs = userInput.split(" ");
String command = userInputs[0];
String response;
try {
switch (command) {
case "bye":
if (userInput.equals("bye")) {
response = Duke.BYE;
return response;
} else {
throw DukeException.DukeInvalidCommand();
}
case "list":
if (userInput.equals("list")) {
response = this.taskList.toString();
return response;
} else {
throw DukeException.DukeInvalidCommand();
}
case "mark":
try {
int index = Integer.parseInt(userInput.substring(MARK_LENGTH)) - 1;
response = this.taskList.markTaskAsDone(index);
writeTasks();
return response;
} catch (NumberFormatException e) {
throw DukeException.DukeInvalidIndex();
} catch (IndexOutOfBoundsException e) {
throw DukeException.DukeInvalidIndex();
} catch (DukeException d) {
throw d;
}
case "unmark":
try {
int index = Integer.parseInt(userInput.substring(UNMARK_LENGTH)) - 1;
response = this.taskList.unmarkTaskAsDone(index);
writeTasks();
return response;
} catch (NumberFormatException e) {
throw DukeException.DukeInvalidIndex();
} catch (IndexOutOfBoundsException e) {
throw DukeException.DukeInvalidIndex();
} catch (DukeException d) {
throw d;
}
case "delete":
try {
int index = Integer.parseInt(userInput.substring(DELETE_LENGTH)) - 1;
response = this.taskList.deleteTaskAtIndex(index);
writeTasks();
return response;
} catch (IndexOutOfBoundsException e) {
throw DukeException.DukeInvalidIndex();
}
case "find":
try {
ArrayList<Task> matchingTasks = this.parser.findTasksByKeyword(userInput,
this.taskList.getTasks());
response = this.ui.getMatchingTasksMessage(matchingTasks);
return response;
} catch (DukeException d) {
throw d;
}
default:
Task task = this.parser.parseTaskFromUi(command, userInput);
if (this.parser.isDuplicate(task, this.taskList.getTasks())) {
throw DukeException.DukeDuplicate();
}
response = this.taskList.addTask(task);
writeTasks();
return response;
}
} catch (DukeException d) {
response = this.ui.getErrorMessage(d);
return response;
}
}
Example from src/main/java/parser/Parser.java lines 43-93:
public Task parseTaskFromUi(String command, String userInput) throws DukeException {
assert command != null && userInput != null;
switch (command) {
case "todo":
try {
String description = userInput.split(" ", 2)[1];
description = description.trim();
if (description.equals("")) {
throw DukeException.DukeDescriptionEmpty();
}
return new Todo(description);
} catch (IndexOutOfBoundsException e) {
throw DukeException.DukeDescriptionEmpty();
} catch (DukeException d) {
throw DukeException.DukeDescriptionEmpty();
}
case "deadline":
try {
String[] descriptionAndTime = userInput.substring(9).split(" /by ");
String description = descriptionAndTime[0].trim();
if (description.equals("")) {
throw DukeException.DukeDescriptionEmpty();
}
LocalDate deadlineTime = parseDate(descriptionAndTime[1].trim());
return new Deadline(description, deadlineTime);
} catch (DukeException d) {
throw d;
} catch (Exception e) {
throw DukeException.DukeInvalidCommand();
}
case "event":
try {
String[] descriptionAndTime = userInput.substring(6).split(" /at ");
String description = descriptionAndTime[0].trim();
if (description.equals("")) {
throw DukeException.DukeDescriptionEmpty();
}
LocalDate eventTime = parseDate(descriptionAndTime[1].trim());
return new Event(description, eventTime);
} catch (DukeException d) {
throw d;
} catch (Exception e) {
throw DukeException.DukeInvalidCommand();
}
default:
throw DukeException.DukeInvalidCommand();
}
}
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/duke/Duke.java lines 40-44:
/**
* (Another) constructs Duke which directly parse the input to storage attribute.
*
* @param storage any object of IStorage class.
*/
Example from src/main/java/task/Deadline.java lines 24-29:
/**
* (Another) constructs Deadline.
*
* @param description the description for the task.
* @param DeadlineTime deadline time for the task.
*/
Example from src/main/java/task/Event.java lines 24-29:
/**
* (Another) constructs Event.
*
* @param description the description for the task.
* @param eventTime status of the task.
*/
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.
@vishandi 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
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/duke/Duke.javalines101-185:Example from
src/main/java/parser/Parser.javalines43-93: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/duke/Duke.javalines40-44:Example from
src/main/java/task/Deadline.javalines24-29:Example from
src/main/java/task/Event.javalines24-29: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.