@NicholasT1 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/yapbot/main/MainWindow.java lines 53-95:
private void handleUserInput() {
String input = userInput.getText();
try {
String response = yapBot.getResponse(input);
assert !response.isEmpty() : "No Response from YapBot";
dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input, userImage),
DialogBox.getYapBotDialog(response, yapBotImage, false)
);
} catch (YapBotException e) {
dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input, userImage),
DialogBox.getYapBotDialog(e.getMessage(), errorImage, true)
);
} catch (NumberFormatException e) {
String message = "Error, Natural Language Processing Module offline...\nSpecify "
+ "Task number instead (eg. \"1\", \"2\").";
dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input, userImage),
DialogBox.getYapBotDialog(message, errorImage, true)
);
} catch (DateTimeParseException e) {
String message = "Error, Dynamic DateTime Module offline."
+ "\nDate & Time should be one of these formats:"
+ "\n Date & Time - \"5pm 2024/09/01\""
+ "\n Date Only (Time defaults to 8am) - \"2024/09/01\""
+ "\n Time Only (Date defaults to today) - \"5pm\"";
dialogContainer.getChildren().addAll(
DialogBox.getUserDialog(input, userImage),
DialogBox.getYapBotDialog(message, errorImage, true)
);
} finally {
userInput.clear();
if (yapBot.shouldExit()) {
Platform.exit();
}
}
}
Example from src/main/java/yapbot/util/Storage.java lines 45-112:
public ArrayList<Task> load() throws YapBotException {
Scanner s = null;
try {
// Creates the file if it does not exist
if (!file.exists()) {
if (file.getParentFile() != null) {
file.getParentFile().mkdirs();
}
file.createNewFile();
}
s = new Scanner(file);
ArrayList<Task> result = new ArrayList<>();
while (s.hasNext()) {
String[] taskData = s.nextLine().split("/");
String taskType = taskData[0];
switch (taskType) {
case "T": {
Task task = this.generateToDo(taskData);
result.add(task);
break;
}
case "D": {
Task task = this.generateDeadline(taskData);
result.add(task);
break;
}
case "E": {
Task task = this.generateEvent(taskData);
result.add(task);
break;
}
// Handles the case where the tasktype may not exist due to file corruption
default: {
throw new TaskParseException("Corrupted File Found.");
}
}
}
s.close();
return result;
} catch (IOException e) {
throw new YapBotException("Error, save file could not be created."
+ "\nYour tasks from this session will not be saved.");
} catch (NumberFormatException | DateTimeParseException | TaskParseException e) {
// Covers parsing errors due to file corruption
s.close();
this.file.delete();
try {
this.file.createNewFile();
} catch (IOException ignored) {
// IOException would have been thrown already if the file cannot be created.
}
throw new YapBotException("Save data detected...load failed.\nCorrupted data found."
+ "\nYapBot will execute without prior data.");
}
}
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
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.
@NicholasT1 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/yapbot/main/MainWindow.javalines53-95:Example from
src/main/java/yapbot/util/Storage.javalines45-112: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
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.