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/Duke.java lines 33-85:
public void start(Stage stage) {
//The container for the content of the chat to scroll.
scrollPane = new ScrollPane();
dialogContainer = new VBox();
scrollPane.setContent(dialogContainer);
userInput = new TextField();
sendButton = new Button("Send");
AnchorPane mainLayout = new AnchorPane();
mainLayout.getChildren().addAll(scrollPane, userInput, sendButton);
scene = new Scene(mainLayout);
stage.setScene(scene);
stage.show();
stage.setTitle("Duke");
stage.setResizable(false);
stage.setMinHeight(600.0);
stage.setMinWidth(400.0);
mainLayout.setPrefSize(400.0, 600.0);
scrollPane.setPrefSize(385, 535);
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
scrollPane.setVvalue(1.0);
scrollPane.setFitToWidth(true);
dialogContainer.setPrefHeight(Region.USE_COMPUTED_SIZE);
userInput.setPrefWidth(325.0);
sendButton.setPrefWidth(55.0);
AnchorPane.setTopAnchor(scrollPane, 1.0);
AnchorPane.setBottomAnchor(sendButton, 1.0);
AnchorPane.setRightAnchor(sendButton, 1.0);
AnchorPane.setLeftAnchor(userInput , 1.0);
AnchorPane.setBottomAnchor(userInput, 1.0);
sendButton.setOnMouseClicked((event) -> {
handleUserInput();
});
userInput.setOnAction((event) -> {
handleUserInput();
});
//Scroll down to the end every time dialogContainer's height changes.
dialogContainer.heightProperty().addListener((observable) -> scrollPane.setVvalue(1.0));
}
Example from src/main/java/duke/Parser.java lines 30-75:
public String parse(String input) {
if (input.startsWith(EXIT_COMMAND)) {
return ui.goodbye();
} else if (input.equals(LIST_COMMAND)) {
return ui.listTasks();
} else {
if (input.startsWith(DONE_COMMAND)) {
taskNumber = Integer.parseInt(input.substring(input.indexOf(" ") + 1)) - 1;
assert taskNumber >= 0 : "Task number should be positive";
return ui.markDone(taskNumber);
} else if (input.startsWith(TODO_COMMAND)) {
Todo todo = new Todo(input.substring(input.indexOf(" ") + 1));
return ui.add(todo);
} else if (input.startsWith(DEADLINE_COMMAND)) {
Deadline deadline = new Deadline(input.substring(input.indexOf(" ") + 1, input.indexOf(" /by")),
input.substring(input.indexOf("/by") + 4));
return ui.add(deadline);
} else if (input.startsWith(EVENT_COMMAND)) {
Event event = new Event(input.substring(input.indexOf(" ") + 1, input.indexOf(" /at")),
input.substring(input.indexOf("/at") + 4));
return ui.add(event);
} else if (input.startsWith(DELETE_COMMAND)) {
taskNumber = Integer.parseInt(input.substring(input.indexOf(" ") + 1)) - 1;
assert taskNumber >= 0 : "Task number should be positive";
return ui.delete(taskNumber);
} else if (input.startsWith(FIND_COMMAND)) {
int thingToFind = input.indexOf(" ") + 1;
return ui.findTasks(input.substring(thingToFind));
} else if (input.startsWith(HELP_COMMAND)) {
String helpMessage = "Welcome to the quick help page!\n" +
"Here are some examples of what you can type: \n" +
"\t1) help\n" +
"\t2) list\n" +
"\t3) todo do homework\n" +
"\t4) deadline assignment \\by 2021-09-24\n" +
"\t5) event career fair \\at 2021-09-08\n" +
"\t6) find homework\n" +
"\t7) done 3\n" +
"\t8) delete 1\n" +
"\t9) bye\n";
return helpMessage;
}
}
return "I don't understand. Please try again!";
}
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
Example from src/main/java/duke/Duke.java lines 114-118:
/**
* Prepare the string to be returned to be showed on the GUI
*
* @param input String input that is given by the user.
*/
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 (Subject Only)
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 @nus-se-bot 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.
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/Duke.javalines33-85:Example from
src/main/java/duke/Parser.javalines30-75: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
Example from
src/main/java/duke/Duke.javalines114-118: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 (Subject Only)
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 @nus-se-bot 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.