@daytona65 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
Example from src/main/java/duke/task/Event.java
lines 15-15
:
protected boolean fromHasTime = true;
Example from src/main/java/duke/task/Event.java
lines 16-16
:
protected boolean toHasTime = true;
Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)
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 20-59
:
public TaskList parse(TaskList tasks) throws DukeException {
String input = sc.nextLine();
if ("bye".equals(input)) {
isDone = true;
return tasks;
} else if ("list".equals(input)) {
Ui.listMessage(tasks);
} else if (isMark(input, tasks.size())) {
int taskindex = Integer.parseInt(input.substring(5)) - 1;
tasks.get(taskindex).markAsDone();
Ui.markMessage(tasks.get(taskindex));
} else if (isUnMark(input, tasks.size())) {
int taskindex = Integer.parseInt(input.substring(7)) - 1;
tasks.get(taskindex).markAsNotDone();
Ui.unmarkMessage(tasks.get(taskindex));
} else if (isDelete(input, tasks.size())) {
int taskindex = Integer.parseInt(input.substring(7)) - 1;
tasks.remove(taskindex);
Ui.deleteMessage(tasks.get(taskindex));
} else { //Task Creation
Task task = null;
if (isToDo(input)) {
task = new ToDo(input);
tasks.add(task);
} else if (isDeadline(input)) {
int index = input.indexOf(" /by ");
task = new Deadline(input.substring(0, index), input.substring(index + 5));
tasks.add(task);
} else if (isEvent(input)) {
int fromdex = input.indexOf(" /from ");
int todex = input.indexOf(" /to ");
task = new Event(input.substring(0, fromdex), input.substring(fromdex + 7, todex), input.substring(todex + 5));
tasks.add(task);
} else {
throw new DukeException("Please input a task with either todo, deadline or event prefixed!");
}
Ui.addMessage(task, tasks.size());
}
return tasks;
}
Example from src/main/java/duke/Storage.java
lines 29-80
:
public TaskList readData() {
try {
File data = new File(filePath);
Scanner sc = new Scanner(data);
while (sc.hasNextLine()) {
String Line = sc.nextLine();
char Type = Line.charAt(0);
int isDone = Integer.parseInt(Character.toString(Line.charAt(2)));
Task task = null;
if (Type == 'T') { // T 1 read book
String description = Line.substring(4);
task = new ToDo(description);
if (isDone == 1) {
task.markAsDone();
}
tasks.add(task);
} else if (Type == 'D') { // D 1 read book | June 12 4pm
int dividerIndex = Line.indexOf('|');
String description = Line.substring(4, dividerIndex - 1);
String by = Line.substring(dividerIndex + 2);
try {
task = new Deadline(description, by);
if (isDone == 1) {
task.markAsDone();
}
tasks.add(task);
} catch (DukeException e) {
continue;
}
} else if (Type == 'E') { // E 1 read book | June 12 4pm | June 13 4pm
int firstDividerIndex = Line.indexOf('|');
int lastDividerIndex = Line.lastIndexOf('|');
String description = Line.substring(4, firstDividerIndex - 1);
String from = Line.substring(firstDividerIndex + 2, lastDividerIndex - 1);
String to = Line.substring(lastDividerIndex + 2);
try {
task = new Event(description, from, to);
if (isDone == 1) {
task.markAsDone();
}
tasks.add(task);
} catch (DukeException e) {
continue;
}
}
}
} catch (IOException e) {
System.out.println("readData(): " + e);
}
return tasks;
}
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 Message (Subject Only)
possible problems in commit ea9f565
:
Level-6
possible problems in commit 42458e6
:
Fixed Level 5 and added text ui testing increment
- Not in imperative mood (?)
Suggestion: Follow the given conventions for Git commit messages for future commits (no need to modify past commit messages).
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 [email protected]
if you want to follow up on this post.