Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sharing iP code quality feedback [for @ivorcmx] #2

Open
nus-se-bot opened this issue Feb 11, 2022 · 0 comments
Open

Sharing iP code quality feedback [for @ivorcmx] #2

nus-se-bot opened this issue Feb 11, 2022 · 0 comments

Comments

@nus-se-bot
Copy link

@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 [email protected] if you want to follow up on this post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant