@W3iZhi 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
Example from src/main/java/Talky/Task.java lines 11-11:
protected boolean marked;
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
Example from src/main/java/Talky/Parser.java lines 1-1:
Example from src/main/java/Talky/SaveData.java lines 1-1:
Example from src/main/java/Talky/TalkyException.java lines 1-1:
Suggestion: Follow the package naming convention specified by the coding standard.
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/Talky/Parser.java lines 33-91:
public static String[] commandArgs(String commandLine, String commandType) throws TalkyException {
String args = "";
if (commandLine.split(" ").length == 1) {
if (!(commandType.equals("list") || commandType.equals("bye") || commandType.equals("help"))) {
throw new TalkyException("Invalid Command");
}
} else {
args = commandLine.split(" ", 2)[1];
}
switch (commandType) {
case "list":
break;
case "bye":
break;
case "help":
break;
case "mark":
if (args.split(" ").length != 1) {
throw new TalkyException("Follow this format: mark [index]");
}
return args.split(" ");
case "unmark":
if (args.split(" ").length != 1) {
throw new TalkyException("Follow this format: unmark [index]");
}
return args.split(" ");
case "todo":
if (args.split(" ").length != 1) {
throw new TalkyException("Follow this format: todo [name]");
}
return args.split(" ");
case "deadline":
String[] deadlineArgs = args.split(" /by ");
if (deadlineArgs.length != 2) {
throw new TalkyException("Follow this format: deadline [name] /by [date] [time]");
}
return deadlineArgs;
case "event":
String[] eventArgs = args.split(" /from | /to ");
if (eventArgs.length != 3) {
throw new TalkyException("Follow this format: event [name] /from [date] [time] /to [date] [time]");
}
return eventArgs;
case "delete":
if (args.split(" ").length != 1) {
throw new TalkyException("Follow this format: delete [index]");
}
return args.split(" ");
case "find":
if (args.split(" ").length != 1) {
throw new TalkyException("Follow this format: find [keyword]");
}
return args.split(" ");
default:
throw new TalkyException("Invalid Command");
}
String[] empty = {};
return empty;
}
Example from src/main/java/Talky/SaveData.java lines 31-77:
public ArrayList<Task> loadData() throws TalkyException {
ArrayList<Task> userTasks = new ArrayList<>();
File saveData = new File(filePath);
Parser parser = new Parser();
try {
if (!saveData.exists()) {
saveData.getParentFile().mkdirs();
saveData.createNewFile();
System.out.println("Creating New Save Data");
}
Scanner sc = new Scanner(saveData);
while (sc.hasNext()) {
String[] taskDetails = sc.nextLine().split(" ");
switch (taskDetails[0]) {
case "ToDo":
ToDo newTodo = new ToDo(taskDetails[1]);
newTodo.setMark(Boolean.parseBoolean(taskDetails[2]));
userTasks.add(newTodo);
break;
case "Deadline":
String saveBy = String.join(" ", taskDetails[2], taskDetails[3]);
ArrayList<LocalDateTime> deadlineDate = parser.parseDate(saveBy);
LocalDateTime by = deadlineDate.get(0);
Deadline newDeadline = new Deadline(taskDetails[1], by);
newDeadline.setMark(Boolean.parseBoolean(taskDetails[3]));
userTasks.add(newDeadline);
break;
case "Event":
String saveFrom = String.join(" ", taskDetails[2], taskDetails[3]);
String saveTo = String.join(" ", taskDetails[4], taskDetails[5]);
ArrayList<LocalDateTime> eventDates = parser.parseDate(saveFrom, saveTo);
LocalDateTime from = eventDates.get(0);
LocalDateTime to = eventDates.get(1);
Event newEvent = new Event(taskDetails[1], from, to);
newEvent.setMark(Boolean.parseBoolean(taskDetails[6]));
userTasks.add(newEvent);
break;
}
}
sc.close();
} catch (IOException err) {
throw new TalkyException("Error Creating Save File");
} catch (TalkyException err) {
throw new TalkyException(err.getMessage());
}
return userTasks;
}
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/Talky/Parser.java lines 25-32:
/**
* Return the arguments of given command.
*
* @param commandLine
* @param commandType
* @return command arguments
* @throws TalkyException
*/
Example from src/main/java/Talky/Task.java lines 32-36:
/**
* Set mark status of Task.
*
* @param marked Mark status.
*/
Example from src/main/java/Talky/TaskList.java lines 80-85:
/**
* Add new Deadline of given name and datetime by
*
* @param name Name of deadline
* @param by LocalDateTime of by
*/
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
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.
@W3iZhi 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
Example from
src/main/java/Talky/Task.javalines11-11: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
Example from
src/main/java/Talky/Parser.javalines1-1:Example from
src/main/java/Talky/SaveData.javalines1-1:Example from
src/main/java/Talky/TalkyException.javalines1-1:Suggestion: Follow the package naming convention specified by the coding standard.
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/Talky/Parser.javalines33-91:Example from
src/main/java/Talky/SaveData.javalines31-77: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/Talky/Parser.javalines25-32:Example from
src/main/java/Talky/Task.javalines32-36:Example from
src/main/java/Talky/TaskList.javalines80-85: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
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.