-
Notifications
You must be signed in to change notification settings - Fork 0
Description
@Lan-Jingbo 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
Example from src/main/java/duke/Parser.java lines 68-68:
//int index = Integer.parseInt(splitInput[1]);Suggestion: Remove dead code from the codebase.
Aspect: Method Length
Example from src/main/java/duke/Main.java lines 43-94:
public void start(Stage stage) throws Exception{
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 BOT(Made by Lan Jingbo, Jerry)");
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);
//Step 3
sendButton.setOnMouseClicked((event) -> {
dialogContainer.getChildren().add(getDialogLabel(userInput.getText()));
userInput.clear();
});
userInput.setOnAction((event) -> {
dialogContainer.getChildren().add(getDialogLabel(userInput.getText()));
userInput.clear();
});
dialogContainer.heightProperty().addListener((observable) -> scrollPane.setVvalue(1.0));
sendButton.setOnMouseClicked((event) -> {
handleUserInput();
});
userInput.setOnAction((event) -> {
handleUserInput();
});
}Example from src/main/java/duke/Storage.java lines 47-83:
public ArrayList<Task> extractFile() throws WrongMessageException {
ArrayList<Task> list = new ArrayList<>();
File file = new File(filePath);
if (!file.exists()) {
try {
file.getParentFile().mkdirs();
file.createNewFile();
} catch (Exception e) {
System.out.println(e.getMessage());
}
} else {
try {
Scanner reader = new Scanner(file);
while (reader.hasNextLine()) {
String temp = reader.nextLine();
if (temp.equals("")) continue;
String[] series = temp.split("\\|");
String type = series[0].trim();
if (type.equals("T")) {
Task task = Todo.fromFileDescription(temp);
list.add(task);
} else if (type.equals("E")) {
Task task = Event.fromFileDescription(temp);
list.add(task);
} else if (type.equals("D")) {
Task task = Event.fromFileDescription(temp);
list.add(task);
} else {
throw new WrongMessageException();
}
}
} catch (IOException e) {
assert false : e.getMessage(); // If the file has errors, stop the program execution.
}
}
return list;
}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/duke/Deadline.java lines 25-30:
/**
* To check if the task due in input date.
*
* @param localDate the input date
* @return whether it is on the expected date
*/Example from src/main/java/duke/Deadline.java lines 44-49:
/**
* convert the file information to concrete deadline task.
*
* @param input the string format in the .txt file
* @return the concrete deadline
*/Example from src/main/java/duke/Duke.java lines 111-116:
/**
* mark the targeted task to "complete".
*
* @param target the index of task
* @throws WrongMessageException potential exception
*/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)
possible problems in commit 23ad156:
hi
- Perhaps too short (?)
possible problems in commit f34ef49:
test
- Perhaps too short (?)
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 👍
❗ 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 [email protected] if you want to follow up on this post.