Giter Club home page Giter Club logo

ip's People

Contributors

9temare avatar damithc avatar j-lum avatar jiachen247 avatar

Stargazers

 avatar

ip's Issues

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

@9teMare 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

No easy-to-detect issues ๐Ÿ‘

Aspect: Class size

No easy-to-detect issues ๐Ÿ‘

Aspect: Header Comments

Example from src/main/java/duke/command/AddCommand.java lines 30-37:

    /**
     * Add the given task to the task list.
     * If the task already exists, task will not be added and exception will be thrown.
     *
     * @param taskList the task list to operate on
     * @param ui the ui to operate on
     * @param storage the storage to operate on
     */

Example from src/main/java/duke/command/ClearAllCommand.java lines 15-21:

    /**
     * Clear all tasks in the task list.
     *
     * @param taskList the task list to operate on
     * @param ui the ui to operate on
     * @param storage the storage to operate on
     */

Example from src/main/java/duke/command/Command.java lines 12-20:

    /**
     * Execute the corresponding command.
     * This is an abstract method, all children will have corresponding implementations.
     *
     * @param tasks the TaskList tasks
     * @param ui       the ui
     * @param storage  the storage
     * @throws CortanaException the cortana 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 (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 @9teMare]

@9teMare 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/utils/Parser.java lines 33-156:

    public Parser() {}

    /**
     * Parse input to Command.
     *
     * @param input the user input
     * @return the specific Cortana command
     * @throws CortanaException the cortana exception
     */
    public static Command parse(String input) throws CortanaException {
        boolean isExit = input.toLowerCase().replaceAll("[ |\\t]", "").equals("bye");
        boolean isListCommand = input.toLowerCase().replaceAll("[ |\\t]", "").equals("list");
        boolean isMarkCommand = input.toLowerCase().matches("^mark [-\\d ]+|[\\d ]+");
        boolean isUnmarkCommand = input.toLowerCase().matches("^unmark [-\\d ]+|[\\d ]+");
        boolean isDeleteCommand = input.toLowerCase().matches("^delete [-\\d ]+|[\\d ]+");
        boolean isDeleteAllCommand = input.toLowerCase().matches("^delete all");
        boolean isShowAllOnSameDate = input.toLowerCase()
                .matches("^show all( )?(\\d{4} ?.?/?-?\\d{1,2} ?.?/?-?\\d{1,2})?( )?(\\d{4})?");
        boolean isFindCommand = input.toLowerCase().matches("^find( )? .*");
        boolean isViewSchedules = input.toLowerCase()
                .matches("^view schedules( )?(\\d{4} ?.?/?-?\\d{1,2} ?.?/?-?\\d{1,2})?");
        boolean isEmptyDeadline = input.toLowerCase().replaceAll("[ |\\t]", "").equals("deadline");
        boolean isEmptyEvent = input.toLowerCase().replaceAll("[ |\\t]", "").equals("event");
        boolean isEmptyTodo = input.toLowerCase().replaceAll("[ |\\t]", "").equals("todo");
        boolean isDeadlineWithDescription = input.toLowerCase().matches("^deadline .*");
        boolean isEventWithDescription = input.toLowerCase().matches("^event .*");
        boolean isTodoWithDescription = input.toLowerCase().matches("^todo .*");

        if (isExit) {
            return new ExitCommand();
        }
        if (isListCommand) {
            return new ListCommand();
        }
        if (isMarkCommand) {
            String[] indexesString = input.replaceAll("mark ", "").split(" ");
            int[] arr = Arrays.stream(indexesString).mapToInt(i -> Integer.parseInt(i) - 1).toArray();
            return new MarkCommand(arr);
        }
        if (isUnmarkCommand) {
            String[] indexesString = input.replaceAll("unmark ", "").split(" ");
            int[] arr = Arrays.stream(indexesString).mapToInt(i -> Integer.parseInt(i) - 1).toArray();
            return new UnmarkCommand(arr);
        }
        if (isDeleteCommand) {
            String[] indexesString = input.replaceAll("delete ", "").split(" ");
            int[] arr = Arrays.stream(indexesString).mapToInt(i -> Integer.parseInt(i) - 1).toArray();
            return new DeleteCommand(arr);
        }
        if (isDeleteAllCommand) {
            return new DeleteAllCommand();
        }
        if (isShowAllOnSameDate) {
            boolean isWithoutDateTime = input.replaceAll(" ", "").matches("showall");
            if (isWithoutDateTime) {
                /* user did not specify time */
                throw new CortanaException("Please specify the date time you are looking for!");
            }
            String dateTimeString = input.replaceAll("show all ", "");
            return new ShowAllTasksOnSameDateCommand(parseLocalDateTime(dateTimeString), dateTimeString);
        }
        if (isFindCommand) {
            String keyWord = input.replaceAll("find ", "");
            if (keyWord.isEmpty()) {
                throw new CortanaException("Please specify the keyword you are looking for!");
            } else {
                return new FindCommand(keyWord);
            }
        }

        if (isViewSchedules) {
            boolean isWithoutDateTime = input.replaceAll(" ", "").matches("viewschedules");
            if (isWithoutDateTime) {
                /* user did not specify time */
                throw new CortanaException("Please specify the date time you are looking for!");
            }
            String dateTimeString = input.replaceAll("view schedules ", "");
            return new ViewSchedulesCommand(parseLocalDateTime(dateTimeString).toLocalDate(), dateTimeString);
        }

        if (isEmptyDeadline || isEmptyEvent || isEmptyTodo) {
            /* user does not specify task description*/
            String aOrAn = isEmptyEvent ? "an " : "a ";
            TaskType taskType = isEmptyDeadline ? TaskType.DEADLINE : isEmptyEvent ? TaskType.EVENT : TaskType.TODO;
            throw new CortanaException("OOPS!!! The description of " + aOrAn + taskType
                    + " cannot be empty!");
        }

        boolean hasBy = Pattern.compile("/by .*").matcher(input).find();
        boolean hasAt = Pattern.compile("/at .*").matcher(input).find();
        String description;
        String time;

        if (isDeadlineWithDescription && hasBy) {
            /* valid deadline command */
            String[] actualTask = input.replaceAll("^deadline ", "")
                    .split("/by ");
            description = actualTask[0];
            time = actualTask[1];
            Deadline deadline = new Deadline(description, parseLocalDateTime(time));
            return new AddCommand(deadline);
        } else if (isEventWithDescription && hasAt) {
            /* valid event command */
            String[] actualTask = input.replaceAll("^event ", "").split("/at ");
            description = actualTask[0];
            time = actualTask[1];
            Event event = new Event(description, parseLocalDateTime(time));
            return new AddCommand(event);
        } else if (isTodoWithDescription) {
            /* valid todo command */
            description = input.replaceAll("^todo ", "");
            Todo todo = new Todo(description);
            return new AddCommand(todo);
        } else if (isDeadlineWithDescription) {
            /* deadline without specifying time with /by */
            throw new CortanaException("Please specify the deadline time with the /by keyword!");
        } else if (isEventWithDescription) {
            /* event without specifying time with /at */
            throw new CortanaException("Please specify the event time with the /at keyword!");
        } else {
            /* invalid command */
            throw new CortanaException("I don't know what that means :(");
        }
    }

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/command/AddCommand.java lines 30-36:

    /**
     * Add a task to the task list.
     *
     * @param taskList the task list to operate on
     * @param ui the ui to operate on
     * @param storage the storage to operate on
     */

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

    /**
     * Execute the corresponding command.
     *
     * @param tasks the TaskList tasks
     * @param ui       the ui
     * @param storage  the storage
     * @throws CortanaException the cortana exception
     */

Example from src/main/java/duke/command/DeleteAllCommand.java lines 15-21:

    /**
     * Delete all tasks in the task list.
     *
     * @param taskList the task list to operate on
     * @param ui the ui to operate on
     * @param storage the storage to operate on
     */

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 364b294:

Add support for mark/unmark/delete more than 1 task at the same time through varargs

  • Longer than 72 characters

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.

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.