@ivorcmx We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the iP code further.
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 35-72:
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 80-120:
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/TaskList.java lines 60-67:
/**
* Unmark a task status in the task list
*
* @param command command by user which specify which task
* @param storeList tasklist to be unmarked from
* @return String of response
*
*/
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 165c928:
Added Update functionality
- Not in imperative mood (?)
possible problems in commit 74506d1:
Improved code quality
- Not in imperative mood (?)
possible problems in commit 56f878f:
Added Assert feature
- Not in imperative mood (?)
Suggestion: Follow the given conventions for Git commit messages for future commits (no need to modify past commit messages).
ℹ️ 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.
@ivorcmx We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the iP code further.
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.javalines35-72:Example from
src/main/java/duke/Storage.javalines80-120: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/TaskList.javalines60-67: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
165c928:Added Update functionalitypossible problems in commit
74506d1:Improved code qualitypossible problems in commit
56f878f:Added Assert featureSuggestion: Follow the given conventions for Git commit messages for future commits (no need to modify past commit messages).
ℹ️ 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.