Giter Site home page Giter Site logo

ip's People

Contributors

damithc avatar j-lum avatar jiachen247 avatar zzkzzzz avatar

ip's Issues

Sharing iP code quality feedback [for @zzkzzzz] - Round 2

@zzkzzzz 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/meep/parser/Parser.java lines 37-107:

    public Command parseUserInput(String userInput, List<Task> tasks) throws InvalidInputException {
        boolean isEmptyInput = userInput.trim().length() == 0;
        if (isEmptyInput) {
            throw new InvalidInputException(Messages.MESSAGE_EMPTY_INPUT);
        }

        String[] arr = userInput.split(" ", 2);
        switch (arr[0]) {
        case ExitCommand.COMMAND_WORD:
            if (isValidCommandLength(ExitCommand.COMMAND_LENGTH, arr)) {
                return new ExitCommand();
            }
            break;
        case HelpCommand.COMMAND_WORD:
            if (isValidCommandLength(HelpCommand.COMMAND_LENGTH, arr)) {
                return new HelpCommand();
            }
            break;
        case ListCommand.COMMAND_WORD:
            if (isValidCommandLength(ListCommand.COMMAND_LIST_LENGTH, arr)) {
                // list without date
                return new ListCommand();
            } else if (isValidCommandLength(ListCommand.COMMAND_LIST_DATE_LENGTH, arr)) {
                // list with date given
                return new ListCommand(true, parseDate(arr[1]));
            }
            break;
        case MarkCommand.COMMAND_WORD:
            if (isValidCommandLength(MarkCommand.COMMAND_LENGTH, arr)) {
                int index = parseListIndex(arr[1], tasks);
                assert index >= 0 && index < tasks.size() : Messages.MESSAGE_OUTBOUND_NUMBER;
                return new MarkCommand(index);
            }
            break;
        case UnmarkCommand.COMMAND_WORD:
            if (isValidCommandLength(UnmarkCommand.COMMAND_LENGTH, arr)) {
                int index = parseListIndex(arr[1], tasks);
                assert index >= 0 && index < tasks.size() : Messages.MESSAGE_OUTBOUND_NUMBER;
                return new UnmarkCommand(index);
            }
            break;
        case DeleteCommand.COMMAND_WORD:
            if (isValidCommandLength(DeleteCommand.COMMAND_LENGTH, arr)) {
                int index = parseListIndex(arr[1], tasks);
                assert index >= 0 && index < tasks.size() : Messages.MESSAGE_OUTBOUND_NUMBER;
                return new DeleteCommand(index);
            }
            break;
        case AddCommand.COMMAND_TODO:
            ToDo todo = parseTodoCommand(arr);
            return new AddCommand(todo);
            // Fallthrough
        case AddCommand.COMMAND_DEADLINE:
            Deadline deadline = parseDeadlineCommand(arr);
            return new AddCommand(deadline);
            // Fallthrough
        case AddCommand.COMMAND_EVENT:
            Event event = parseEventCommand(arr);
            return new AddCommand(event);
            // Fallthrough
        case FindCommand.COMMAND_WORD:
            if (isValidCommandLength(FindCommand.COMMAND_LENGTH, arr)) {
                return new FindCommand(arr[1]);
            }
            break;

        default:
            throw new InvalidInputException(Messages.MESSAGE_INVALID_FORMAT);
        }
        throw new InvalidInputException(Messages.MESSAGE_INVALID_FORMAT);
    }

Example from src/main/java/meep/ui/Gui.java lines 54-129:

    public void start(Stage stage) {


        //Step 1. Setting up required components
        //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();


        AnchorPane mainLayout = new AnchorPane();
        mainLayout.getChildren().addAll(scrollPane, userInput, sendButton);

        scene = new Scene(mainLayout);

        stage.setScene(scene);
        stage.show();

        //Step 2. Formatting the window to look as expected
        stage.setTitle("Meep");
        stage.setResizable(false);
        stage.setMinHeight(6000.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);

        // You will need to import `javafx.scene.layout.Region` for this.
        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. Add functionality to handle user input.
        sendButton.setOnMouseClicked((event) -> {
            dialogContainer.getChildren().add(getDialogLabel(userInput.getText()));
            userInput.clear();
        });

        userInput.setOnAction((event) -> {
            dialogContainer.getChildren().add(getDialogLabel(userInput.getText()));
            userInput.clear();
        });

        //Scroll down to the end every time dialogContainer's height changes.
        dialogContainer.heightProperty().addListener((observable) -> scrollPane.setVvalue(1.0));

        //Part 3. Add functionality to handle user input.
        sendButton.setOnMouseClicked((event) -> {
            handleUserInput();
        });

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


    }

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/meep/task/Task.java lines 67-69:

    /**
     * To String.
     */

Example from src/main/java/meep/textui/Ui.java lines 51-53:

    /**
     * Print logo.
     */

Example from src/main/java/meep/textui/Ui.java lines 62-64:

    /**
     * Print bye.
     */

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)

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.

Sharing iP code quality feedback [for @zzkzzzz]

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

Example from src/test/java/meep/storage/StorageTest.java lines 37-37:

        //String filePath = "/src/test/java/Meep/test.txt";

Example from src/test/java/meep/storage/StorageTest.java lines 38-38:

        //String home = System.getProperty("user.dir");

Example from src/test/java/meep/storage/StorageTest.java lines 39-39:

        //String path = home + filePath;

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/meep/parser/Parser.java lines 136-217:

    public Command parseUserInput(String userInput, List<Task> tasks) throws InvalidInputException {
        boolean isEmptyInput = userInput.trim().length() == 0;
        if (isEmptyInput) {
            throw new InvalidInputException(Messages.MESSAGE_EMPTY_INPUT);
        }

        String[] arr = userInput.split(" ", 2);
        switch (arr[0]) {
        case ExitCommand.COMMAND_WORD:
            if (isValidCommandLength(ExitCommand.COMMAND_LENGTH, arr)) {
                return new ExitCommand();
            }
            break;
        case HelpCommand.COMMAND_WORD:
            if (isValidCommandLength(HelpCommand.COMMAND_LENGTH, arr)) {
                return new HelpCommand();
            }
            break;
        case ListCommand.COMMAND_WORD:
            if (isValidCommandLength(ListCommand.COMMAND_LIST_LENGTH, arr)) {
                // list without date
                return new ListCommand();
            } else if (isValidCommandLength(ListCommand.COMMAND_LIST_DATE_LENGTH, arr)) {
                // list with date given
                return new ListCommand(true, parseDate(arr[1]));
            }
            break;
        case MarkCommand.COMMAND_WORD:
            if (isValidCommandLength(MarkCommand.COMMAND_LENGTH, arr)) {
                int index = parseListIndex(arr[1], tasks);
                assert index >= 0 && index < tasks.size() : Messages.MESSAGE_OUTBOUND_NUMBER;
                return new MarkCommand(index);
            }
            break;
        case UnmarkCommand.COMMAND_WORD:
            if (isValidCommandLength(UnmarkCommand.COMMAND_LENGTH, arr)) {
                int index = parseListIndex(arr[1], tasks);
                assert index >= 0 && index < tasks.size() : Messages.MESSAGE_OUTBOUND_NUMBER;
                return new UnmarkCommand(index);
            }
            break;
        case DeleteCommand.COMMAND_WORD:
            if (isValidCommandLength(DeleteCommand.COMMAND_LENGTH, arr)) {
                int index = parseListIndex(arr[1], tasks);
                assert index >= 0 && index < tasks.size() : Messages.MESSAGE_OUTBOUND_NUMBER;
                return new DeleteCommand(index);
            }
            break;
        case AddCommand.COMMAND_TODO:
            if (isValidCommandLength(AddCommand.COMMAND_LENGTH, arr)) {
                String taskTitle = checkEmptyTask(arr[1]);
                assert taskTitle.length() > 0 : Messages.MESSAGE_EMPTY_TASK;
                return new AddCommand(new ToDo(taskTitle));
            }
            break;
        case AddCommand.COMMAND_DEADLINE:
            String[] deadline = parseTaskFormat(arr[1]);
            assert deadline.length == 2 : Messages.MESSAGE_INVALID_COMMAND_LENGTH;
            String deadlineDate = checkPrepositionFormat(deadline[1], AddCommand.COMMAND_DEADLINE);
            String deadlineTitle = checkEmptyTask(deadline[0]);
            assert deadlineTitle.length() > 0 : Messages.MESSAGE_EMPTY_TASK;
            return new AddCommand(new Deadline(deadlineTitle, parseDate(deadlineDate)));
            // Fallthrough
        case AddCommand.COMMAND_EVENT:
            String[] event = parseTaskFormat(arr[1]);
            assert event.length == 2 : Messages.MESSAGE_INVALID_COMMAND_LENGTH;
            String eventDate = checkPrepositionFormat(event[1], AddCommand.COMMAND_EVENT);
            String eventTitle = checkEmptyTask(event[0]);
            assert eventTitle.length() > 0 : Messages.MESSAGE_EMPTY_TASK;
            return new AddCommand(new Event(eventTitle, parseDate(eventDate)));
            // Fallthrough
        case FindCommand.COMMAND_WORD:
            if (isValidCommandLength(FindCommand.COMMAND_LENGTH, arr)) {
                return new FindCommand(arr[1]);
            }
            break;

        default:
            throw new InvalidInputException(Messages.MESSAGE_INVALID_FORMAT);
        }
        throw new InvalidInputException(Messages.MESSAGE_INVALID_FORMAT);
    }

Example from src/main/java/meep/ui/Gui.java lines 54-129:

    public void start(Stage stage) {


        //Step 1. Setting up required components
        //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();


        AnchorPane mainLayout = new AnchorPane();
        mainLayout.getChildren().addAll(scrollPane, userInput, sendButton);

        scene = new Scene(mainLayout);

        stage.setScene(scene);
        stage.show();

        //Step 2. Formatting the window to look as expected
        stage.setTitle("Meep");
        stage.setResizable(false);
        stage.setMinHeight(6000.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);

        // You will need to import `javafx.scene.layout.Region` for this.
        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. Add functionality to handle user input.
        sendButton.setOnMouseClicked((event) -> {
            dialogContainer.getChildren().add(getDialogLabel(userInput.getText()));
            userInput.clear();
        });

        userInput.setOnAction((event) -> {
            dialogContainer.getChildren().add(getDialogLabel(userInput.getText()));
            userInput.clear();
        });

        //Scroll down to the end every time dialogContainer's height changes.
        dialogContainer.heightProperty().addListener((observable) -> scrollPane.setVvalue(1.0));

        //Part 3. Add functionality to handle user input.
        sendButton.setOnMouseClicked((event) -> {
            handleUserInput();
        });

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


    }

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/meep/commands/Command.java lines 18-23:

    /**
     * Execute method should be implemented by child classes.
     *
     * @param tasks the task list.
     * @return None
     */

Example from src/main/java/meep/storage/Storage.java lines 72-79:

    /**
     * Read task date file.
     *
     * @param path the path of the file.
     * @return the list of tasks.
     * @throws IOException           If the file path is invalid.
     * @throws InvalidInputException If the datetime format is invalid.
     */

Example from src/main/java/meep/task/Task.java lines 52-54:

    /**
     * Mark task isDone.
     */

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)

No easy-to-detect issues ๐Ÿ‘

โ„น๏ธ 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.