@AAlghrairy 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/Parser.java
lines 22-82
:
public String processMessage(String message, TaskList tasks, Storage storage) throws DukeException {
if (isExitCommand(message)) {
return null;
}
String confirmationMessage = null;
String currentMessage = getFirstWord(message);
Task currentTask;
int index;
switch (currentMessage) {
case "help":
confirmationMessage = Ui.COMMANDS_lIST;
break;
case "list":
confirmationMessage = getListAsString(tasks);
break;
case "sort":
sortList(message, tasks, storage);
confirmationMessage = confirmSort(tasks);
break;
case "mark":
index = getIndexFromMessage(message);
currentTask = tasks.getTaskAtIndex(index);
modifyTaskMark(currentTask, ConfirmCodes.MARK);
confirmationMessage = confirmMarkChange(currentTask, ConfirmCodes.MARK);
break;
case "unmark":
index = getIndexFromMessage(message);
currentTask = tasks.getTaskAtIndex(index);
modifyTaskMark(currentTask, ConfirmCodes.UNMARK);
confirmationMessage = confirmMarkChange(currentTask, ConfirmCodes.UNMARK);
break;
case "delete":
index = getIndexFromMessage(message);
currentTask = tasks.getTaskAtIndex(index);
deleteTask(index , tasks, storage);
confirmationMessage = confirmTaskDeletion(currentTask, tasks);
break;
case "find":
confirmationMessage = getResultsOfFind(message, tasks);
break;
case "todo":
currentTask = parseMessageContents(message, TaskTypes.TODO);
addTask(currentTask, storage, tasks);
confirmationMessage = confirmTaskAddition(currentTask, tasks);
break;
case "deadline":
currentTask = parseMessageContents(message, TaskTypes.DEADLINE);
addTask(currentTask, storage, tasks);
confirmationMessage = confirmTaskAddition(currentTask, tasks);
break;
case "event":
currentTask = parseMessageContents(message, TaskTypes.EVENT);
addTask(currentTask, storage, tasks);
confirmationMessage = confirmTaskAddition(currentTask, tasks);
break;
default:
throwInvalidInput();
}
return confirmationMessage;
}
Example from src/main/java/duke/Storage.java
lines 43-106
:
public List<Task> load() throws DukeException, IOException {
List<Task> tasks = new ArrayList<>();
try {
Scanner s = new Scanner(dukeFile);
while (s.hasNext()) {
String currLine = s.nextLine();
String[] currLineArr = currLine.split("\\|");
switch (currLineArr[0]) {
case "T":
Task toDoTask = new ToDo(currLineArr[2]);
if (currLineArr[1].equals("X")) {
toDoTask.markDone();
}
tasks.add(toDoTask);
break;
case "D":
LocalDate currDate = LocalDate.parse(currLineArr[3], Task.YEAR_FORMAT);
LocalTime currTime = currLineArr.length < 5 ? null : LocalTime.parse(currLineArr[4],
Task.TIME_FORMAT);
Task deadlineTask = currTime == null ? new Deadline(currLineArr[2], currDate) : new Deadline(
currLineArr[2], currDate, currTime);
if (currLineArr[1].equals("X")) {
deadlineTask.markDone();
}
tasks.add(deadlineTask);
break;
case "E":
LocalDate dateForEvent = LocalDate.parse(currLineArr[3], Task.YEAR_FORMAT);
LocalTime beginTime = LocalTime.parse(currLineArr[4], Task.TIME_FORMAT);
LocalTime endTime = LocalTime.parse(currLineArr[5], Task.TIME_FORMAT);
Task eventTask = new Event(currLineArr[2], dateForEvent, beginTime, endTime);
if (currLineArr[1].equals("X")) {
eventTask.markDone();
}
tasks.add(eventTask);
break;
default:
assert false : "File contains illegal modifications";
break;
}
}
} catch (FileNotFoundException e) {
if (!dukeFolder.exists()) {
dukeFolder.mkdirs();
}
if (!dukeFile.exists()) {
dukeFile.createNewFile();
}
throw new DukeException("Pardon me! But the file was not found");
}
return tasks;
}
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
No easy-to-detect issues ๐
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 [email protected]
if you want to follow up on this post.