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 @S-Aishvarya] - Round 2 #2

Open
soc-se-bot opened this issue Mar 19, 2024 · 0 comments
Open

Sharing iP code quality feedback [for @S-Aishvarya] - Round 2 #2

soc-se-bot opened this issue Mar 19, 2024 · 0 comments

Comments

@soc-se-bot
Copy link

@S-Aishvarya 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

Example from src/main/java/duke/task/Task.java lines 8-8:

    private boolean marked = false;

Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)

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/Duke.java lines 144-144:

                //this.stop();

Example from src/main/java/duke/Duke.java lines 148-148:

//            Alert alert = new Alert(Alert.AlertType.ERROR, de.getMessage());

Example from src/main/java/duke/task/Deadline.java lines 89-89:

//        sb.append(getSeqNo()).append(" | ");

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/duke/Duke.java lines 46-115:

    public void start(Stage stage) {
        //assuming filepath is specified as the only argument
        try {
            String filePath;
            if (this.getParameters().getRaw().size() > 0) {
                filePath = this.getParameters().getRaw().get(0);
            } else {
                filePath = "";
            }
            loadTaskListFromFile(filePath);
        }catch (DukeException de) {
            Alert alert = new Alert(Alert.AlertType.ERROR, de.getMessage());
        }

        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 scene = new Scene(mainLayout);
        stage.setScene(scene);
        stage.show();

        //Step 2
        stage.setTitle("Lighthouse");
        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) -> {
            handleUserInput();
        });

        userInput.setOnAction((event) -> {
            handleUserInput();
        });

        dialogContainer.heightProperty().addListener((observable -> scrollPane.setVvalue(1.0)));


    }

Example from src/main/java/duke/Parser.java lines 20-67:

    public static Command parse(String commandText) throws DukeException{
        Command command;
        if (commandText.equals("bye")) {
            command = new ExitCommand();
        } else if (commandText.contains("mark")) {
            int index = commandText.indexOf(" ");
            boolean isMarked = false;
            String argVal = commandText.substring(index+1);
            int itemNo = Integer.parseInt(argVal);
            if (commandText.startsWith("mark")) {
                isMarked = true;
            } else if (commandText.startsWith("unmark")) {
                isMarked = false;
            }
            command = new UpdateCommand(itemNo, isMarked);
        } else if (commandText.equals("list")) {
            command = new ListCommand();
        } else if (commandText.startsWith("todo")
                || commandText.startsWith("event")
                || commandText.startsWith("deadline")
                || commandText.startsWith("fixedduration") ) {
            Task todo = null;
            todo = handleTodoEventDeadline(commandText);
            command = new AddCommand(todo);
        } else if (commandText.startsWith("delete")) {
            int index = commandText.indexOf(" ");
            if (index <= 0) {
                throw new DukeException("OMG! Item no to delete is empty. Cannot accept.");
            }
            String argVal = commandText.substring(index+1);
            int itemNo = Integer.parseInt(argVal);
            command = new DeleteCommand(itemNo);
        } else if(commandText.startsWith("find")) {
            int index = commandText.indexOf(" ");
            if (index <= 0) {
                throw new DukeException("OMG! Query parameter is empty. Cannot accept.");
            }
            String searchString = commandText.substring(index+1);
            searchString = searchString.trim();
            if ("".equals(searchString)) {
                throw new DukeException("OMG! Query parameter is empty. Cannot accept.");
            }
            command = new FindCommand(searchString);
        } else {
            throw new DukeException("Oh dear! I do not understand this command! Try again!");
        }
        return command;
    }

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/Duke.java lines 30-34:

    /**
     * The entry point of application.
     *
     * @param args the input arguments
     */

Example from src/main/java/duke/Parser.java lines 12-19:

    /**
     * Parse command.
     *
     * @param commandText the command text entered by user
     * @return the command object of type Command containing parsed details of tasjs
     * @throws DukeException when the parser cannot parse user input into appropriate command objects
     *
     */

Example from src/main/java/duke/Storage.java lines 57-62:

    /**
     * Store the tasks into flat file.
     *
     * @param content the details of tasks in the task list
     * @throws DukeException the duke 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

No easy-to-detect issues 👍

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.

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