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 @larrywang0701] #9

Open
nus-se-bot opened this issue Sep 16, 2023 · 0 comments
Open

Sharing iP code quality feedback [for @larrywang0701] #9

nus-se-bot opened this issue Sep 16, 2023 · 0 comments

Comments

@nus-se-bot
Copy link

@larrywang0701 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

Example from src/main/java/command/CommandDeadlineHandler.java lines 19-20:

            }
            else{

Example from src/main/java/command/CommandDeleteHandler.java lines 17-18:

        }
        catch (NumberFormatException e){

Example from src/main/java/command/CommandEventHandler.java lines 20-21:

            }
            else{

Suggestion: As specified by the coding standard, use egyptian style braces.

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/main/Ui.java lines 122-122:

        //text.setTextAlignment(isUser ? TextAlignment.RIGHT : TextAlignment.LEFT);

Example from src/main/java/main/Ui.java lines 127-127:

        //VBox.setMargin(messageBubble, new Insets(0, 0, 0, isUser ? 350 : 0));

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/main/Ui.java lines 22-80:

    public void start(Stage primaryStage) throws Exception {
        INSTANCE = this;
        this.window = primaryStage;
        AnchorPane anchorPane = new AnchorPane();
        ScrollPane scrollPane = new ScrollPane();
        VBox dialogContainer = new VBox();
        this.dialogContainer = dialogContainer;
        scrollPane.setContent(dialogContainer);
        scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
        scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
        TextField messageInputArea = new TextField();
        messageInputArea.setPrefSize(350, 20);
        messageInputArea.setLayoutX(0);
        messageInputArea.setLayoutY(600);
        Button sendMessageButton = new Button("Send");
        sendMessageButton.setPrefSize(50, 20);
        sendMessageButton.setLayoutX(350);
        sendMessageButton.setLayoutY(600);
        scrollPane.setPrefSize(400, 590);
        anchorPane.getChildren().addAll(scrollPane, messageInputArea, sendMessageButton);
        Scene mainScene = new Scene(anchorPane);
        primaryStage.setTitle("Chat with " + Main.getInstance().getName());
        primaryStage.setResizable(false);
        primaryStage.setMinHeight(600);
        primaryStage.setMinWidth(400);
        anchorPane.setPrefSize(400, 600);
        primaryStage.setScene(mainScene);
        primaryStage.show();
        primaryStage.setOnCloseRequest(event -> {
            ButtonType exitBtn = new ButtonType("Exit");
            ButtonType cancelBtn = new ButtonType("Cancel");
            Alert closeConfirmation = new Alert(Alert.AlertType.CONFIRMATION,"", cancelBtn, exitBtn);
            closeConfirmation.setHeaderText("Do you really want to exit?");
            closeConfirmation.showAndWait().ifPresent(
                    result->{
                        if(result == exitBtn){
                            this.byeAndExit();
                        }
                    }
            );
            event.consume();
        });

        sendMessageButton.setOnMouseClicked(event -> {
            String message = messageInputArea.getText();
            messageInputArea.setText("");
            this.addMessageBubble(message, true);
            Main.getInstance().getParser().executeCommand(message);
        });

        messageInputArea.setOnAction(event -> {
            String message = messageInputArea.getText();
            messageInputArea.setText("");
            this.addMessageBubble(message, true);
            Main.getInstance().getParser().executeCommand(message);
        });

        Main.getInstance().getParser().executeCommand("intro");
    }

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/main/Main.java lines 48-52:

    /**
     * Main function for the program
     *
     * @param args The arugments from JVM
     */

Example from src/main/java/main/Main.java lines 76-80:

    /**
     * Return the name of the chat bot
     *
     * @return the name
     */

Example from src/main/java/main/Main.java lines 85-87:

    /**
     * Exit the program
     */

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

No easy-to-detect issues 👍

Aspect: Binary files in repo

No easy-to-detect 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.

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