@reaneechua 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/hewwokitty/parser/Parser.java lines 27-79:
public boolean processUserCommands(String userInput, TaskList taskList) {
assert userInput != null : "User input should not be null";
assert taskList != null : "TaskList should not be null";
this.userInput = userInput;
String userString = this.userInput.toLowerCase();
switch (userString.split(" ", 2)[0]) {
case "bye":
return false;
case "list":
System.out.print(taskList);
break;
case "mark":
try {
int markTaskNum = Integer.parseInt(userString.split(" ")[1]);
taskList.markDone(markTaskNum);
Storage.writeToFile(taskList);
} catch (IllegalArgumentException e) {
Ui.printInvalidTaskNumber();
}
break;
case "unmark":
try {
int unmarkTaskNum = Integer.parseInt(userString.split(" ")[1]);
taskList.unmarkDone(unmarkTaskNum);
Storage.writeToFile(taskList);
} catch (IllegalArgumentException e) {
Ui.printInvalidTaskNumber();
}
break;
case "todo":
case "deadline":
case "event":
try {
taskList.addTask(userString);
Storage.writeToFile(taskList);
} catch (IllegalArgumentException e) {
Ui.printInvalidDate();
}
break;
case "delete":
int deleteTaskNum = Integer.parseInt(userString.split(" ")[1]);
taskList.removeTask(deleteTaskNum);
Storage.writeToFile(taskList);
break;
case "find":
taskList.findTasks(userString);
break;
default:
Ui.printInvalidCommand();
break;
}
return true;
}
Example from src/main/java/hewwokitty/storage/Storage.java lines 42-107:
public static TaskList readFromFile() {
File file = new File("./data/hewwoTasks.txt");
TaskList taskList = new TaskList();
if (!file.exists()) {
return taskList;
}
try (Scanner scanner = new Scanner(file)) {
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
Task t = null;
String marked;
String command;
String temp;
boolean isMarked = false;
String message;
try {
command = line.split("\\|")[0];
temp = line.split("\\|", 2)[1];
} catch (Exception e) {
return taskList;
}
switch (command) {
case "T":
marked = temp.split("\\|")[0];
isMarked = checkMarked(marked);
message = temp.split("\\|", 2)[1];
t = new Todo(message);
if (isMarked) {
t.markAsDoneFile();
}
break;
case "D":
marked = temp.split("\\|")[0];
isMarked = checkMarked(marked);
message = temp.split("\\|")[1];
String byDate = temp.split("\\|")[2];
t = new Deadline(message, byDate);
if (isMarked) {
t.markAsDoneFile();
}
break;
case "E":
marked = temp.split("\\|")[0];
isMarked = checkMarked(marked);
message = temp.split("\\|")[1];
String fromDate = temp.split("\\|")[2];
String toDate = temp.split("\\|")[3];
t = new Event(message, fromDate, toDate);
if (isMarked) {
t.markAsDoneFile();
}
break;
default:
break;
}
if (t != null) {
taskList.addTaskFromFile(t);
}
}
} catch (FileNotFoundException e) {
return taskList;
}
return taskList;
}
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/hewwokitty/task/TaskList.java lines 20-23:
/**
* Get the number of Tasks in a TaskList
* @return An int with the number of Tasks in the TaskList
*/
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 Messages
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.
@reaneechua 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/hewwokitty/parser/Parser.javalines27-79:Example from
src/main/java/hewwokitty/storage/Storage.javalines42-107: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/hewwokitty/task/TaskList.javalines20-23: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 Messages
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.