@ivorcmx 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 39-112:
public void start(Stage stage) throws IOException {
//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("DukeGenie");
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) -> {
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) -> {
try {
handleUserInput();
} catch (IOException e) {
e.printStackTrace();
}
});
userInput.setOnAction((event) -> {
try {
handleUserInput();
} catch (IOException e) {
e.printStackTrace();
}
});
}
Example from src/main/java/duke/Storage.java lines 40-77:
private static void restoreFromFile(ArrayList<Task> storeList) throws FileNotFoundException {
File f = new File(getNewFilePath());
try (Scanner s = new Scanner(f)) {
while (s.hasNextLine()) {
String typeOfTask = s.nextLine();
if (typeOfTask.equals("e")) {
Event created = new Event(s.nextLine(), s.nextLine());
if (s.nextLine().equals("1")) {
created.setMark();
} else {
created.setUnmark();
}
storeList.add(created);
continue;
} else if (typeOfTask.equals("d")) {
Deadline created = new Deadline(s.nextLine(), s.nextLine());
if (s.nextLine().equals("1")) {
created.setMark();
} else {
created.setUnmark();
}
storeList.add(created);
continue;
} else if (typeOfTask.equals("t")) {
Todo created = new Todo(s.nextLine());
if (s.nextLine().equals("1")) {
created.setMark();
} else {
created.setUnmark();
}
storeList.add(created);
continue;
}
}
} catch (FileNotFoundException e) {
assert false;
}
}
Example from src/main/java/duke/Storage.java lines 85-125:
public static void saveList(ArrayList<Task> arrlist) throws IOException {
int sizeOfList = arrlist.size();
String newFilePath = getNewFilePath();
eraseList(newFilePath);
FileWriter fw = new FileWriter(newFilePath, true);
for (int i = 0; i < sizeOfList; i++) {
Task t = arrlist.get(i);
if (t.getType() == 'e') {
Event e = (Event) t;
fw.write("e");
fw.write("\n");
fw.write(t.description);
fw.write("\n");
fw.write(e.eventDateTime);
fw.write("\n");
fw.write(t.isDone ? "1" : "0");
fw.write("\n");
} else if (t.getType() == 'd') {
Deadline d = (Deadline) t;
fw.write("d");
fw.write("\n");
fw.write(t.description);
fw.write("\n");
fw.write(d.deadlineDateTime);
fw.write("\n");
fw.write(t.isDone ? "1" : "0");
fw.write("\n");
} else if (t.getType() == 't') {
Todo td = (Todo) t;
fw.write("t");
fw.write("\n");
fw.write(t.description);
fw.write("\n");
fw.write(t.isDone ? "1" : "0");
fw.write("\n");
} else {
assert sizeOfList == 0 : sizeOfList;
}
}
fw.close();
}
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 141-144:
/**
* You should have your own function to generate a response to user input.
* Replace this stub with your completed method.
*/
Example from src/main/java/duke/Launcher.java lines 5-7:
/**
* A launcher class to workaround classpath issues.
*/
Example from src/main/java/duke/Storage.java lines 35-39:
/**
* restore list from memory into chatbot
* @param storeList arraylist to be populated
* @throws FileNotFoundException when there is no such file in memory
*/
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 4dc747a:
Updated README.md
- Not in imperative mood (?)
possible problems in commit 22f59f8:
Updated build.gradle
- Not in imperative mood (?)
possible problems in commit 3afef48:
Updated README.md
- Not in imperative mood (?)
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 cs2103@comp.nus.edu.sg if you want to follow up on this post.
@ivorcmx 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.javalines39-112:Example from
src/main/java/duke/Storage.javalines40-77:Example from
src/main/java/duke/Storage.javalines85-125: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.javalines141-144:Example from
src/main/java/duke/Launcher.javalines5-7:Example from
src/main/java/duke/Storage.javalines35-39: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
4dc747a:Updated README.mdpossible problems in commit
22f59f8:Updated build.gradlepossible problems in commit
3afef48:Updated README.mdSuggestion: 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
cs2103@comp.nus.edu.sgif you want to follow up on this post.