Git Product home page Git Product logo

ip's People

Contributors

damithc avatar j-lum avatar jiachen247 avatar vishandi avatar

ip's Issues

Sharing iP code quality feedback [for @vishandi]

@vishandi 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 95-179:

    public String processUserInput(String userInput) {
        assert userInput != null;
        String[] userInputs = userInput.split(" ");
        String command = userInputs[0];
        String response;
        try {
            switch (command) {
            case "bye":
                if (userInput.equals("bye")) {
                    response = Duke.BYE;
                    return response;
                } else {
                    throw DukeException.DukeInvalidCommand();
                }

            case "list":
                if (userInput.equals("list")) {
                    response = this.taskList.toString();
                    return response;
                } else {
                    throw DukeException.DukeInvalidCommand();
                }

            case "mark":
                try {
                    int index = Integer.parseInt(userInput.substring(MARK_LENGTH)) - 1;
                    response = this.taskList.markTaskAsDone(index);
                    writeTasks();
                    return response;
                } catch (NumberFormatException e) {
                    throw DukeException.DukeInvalidIndex();
                } catch (IndexOutOfBoundsException e) {
                    throw DukeException.DukeInvalidIndex();
                } catch (DukeException d) {
                    throw d;
                }

            case "unmark":
                try {
                    int index = Integer.parseInt(userInput.substring(UNMARK_LENGTH)) - 1;
                    response = this.taskList.unmarkTaskAsDone(index);
                    writeTasks();
                    return response;
                } catch (NumberFormatException e) {
                    throw DukeException.DukeInvalidIndex();
                } catch (IndexOutOfBoundsException e) {
                    throw DukeException.DukeInvalidIndex();
                } catch (DukeException d) {
                    throw d;
                }

            case "delete":
                try {
                    int index = Integer.parseInt(userInput.substring(DELETE_LENGTH)) - 1;
                    response = this.taskList.deleteTaskAtIndex(index);
                    writeTasks();
                    return response;
                } catch (IndexOutOfBoundsException e) {
                    throw DukeException.DukeInvalidIndex();
                }

            case "find":
                try {
                    ArrayList<Task> matchingTasks = this.parser.findTasksByKeyword(userInput,
                            this.taskList.getTasks());
                    response = this.ui.getMatchingTasksMessage(matchingTasks);
                    return response;
                } catch (DukeException d) {
                    throw d;
                }

            default:
                Task task = this.parser.parseTaskFromUi(command, userInput);
                if (this.parser.isDuplicate(task, this.taskList.getTasks())) {
                    throw DukeException.DukeDuplicate();
                }
                response = this.taskList.addTask(task);
                writeTasks();
                return response;
            }
        } catch (DukeException d) {
             response = this.ui.getErrorMessage(d);
             return response;
        }
    }

Example from src/main/java/parser/Parser.java lines 40-90:

    public Task parseTaskFromUi(String command, String userInput) throws DukeException {
        assert command != null && userInput != null;
        switch (command) {
        case "todo":
            try {
                String description = userInput.split(" ", 2)[1];
                description = description.trim();
                if (description.equals("")) {
                    throw DukeException.DukeDescriptionEmpty();
                }
                return new Todo(description);
            } catch (IndexOutOfBoundsException e) {
                throw DukeException.DukeDescriptionEmpty();
            } catch (DukeException d) {
                throw DukeException.DukeDescriptionEmpty();
            }

        case "deadline":
            try {
                String[] descriptionAndTime = userInput.substring(9).split(" /by ");
                String description = descriptionAndTime[0].trim();
                if (description.equals("")) {
                    throw DukeException.DukeDescriptionEmpty();
                }
                LocalDate deadlineTime = LocalDate.parse(descriptionAndTime[1].trim());
                return new Deadline(description, deadlineTime);
            } catch (DukeException d) {
                throw DukeException.DukeDescriptionEmpty();
            } catch (Exception e) {
                throw DukeException.DukeInvalidCommand();
            }

        case "event":
            try {
                String[] descriptionAndTime = userInput.substring(6).split(" /at ");
                String description = descriptionAndTime[0].trim();
                if (description.equals("")) {
                    throw DukeException.DukeDescriptionEmpty();
                }
                LocalDate eventTime = LocalDate.parse(descriptionAndTime[1].trim());
                return new Event(description, eventTime);
            } catch (DukeException d) {
                throw DukeException.DukeDescriptionEmpty();
            } catch (Exception e) {
                throw DukeException.DukeInvalidCommand();
            }

        default:
            throw DukeException.DukeInvalidCommand();
        }
    }

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 49-53:

    /**
     * The main logic of the process of Duke.
     * @param args
     * @throws DukeException
     */

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

    /**
     * Initialize Duke by reading from the default file.
     * Greet Users.
     * @throws DukeException
     */

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

    /**
     * The main process of how Duke runs.
     */

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.

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

@vishandi 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/duke/Duke.java lines 101-185:

    public String processUserInput(String userInput) {
        assert userInput != null;
        String[] userInputs = userInput.split(" ");
        String command = userInputs[0];
        String response;
        try {
            switch (command) {
            case "bye":
                if (userInput.equals("bye")) {
                    response = Duke.BYE;
                    return response;
                } else {
                    throw DukeException.DukeInvalidCommand();
                }

            case "list":
                if (userInput.equals("list")) {
                    response = this.taskList.toString();
                    return response;
                } else {
                    throw DukeException.DukeInvalidCommand();
                }

            case "mark":
                try {
                    int index = Integer.parseInt(userInput.substring(MARK_LENGTH)) - 1;
                    response = this.taskList.markTaskAsDone(index);
                    writeTasks();
                    return response;
                } catch (NumberFormatException e) {
                    throw DukeException.DukeInvalidIndex();
                } catch (IndexOutOfBoundsException e) {
                    throw DukeException.DukeInvalidIndex();
                } catch (DukeException d) {
                    throw d;
                }

            case "unmark":
                try {
                    int index = Integer.parseInt(userInput.substring(UNMARK_LENGTH)) - 1;
                    response = this.taskList.unmarkTaskAsDone(index);
                    writeTasks();
                    return response;
                } catch (NumberFormatException e) {
                    throw DukeException.DukeInvalidIndex();
                } catch (IndexOutOfBoundsException e) {
                    throw DukeException.DukeInvalidIndex();
                } catch (DukeException d) {
                    throw d;
                }

            case "delete":
                try {
                    int index = Integer.parseInt(userInput.substring(DELETE_LENGTH)) - 1;
                    response = this.taskList.deleteTaskAtIndex(index);
                    writeTasks();
                    return response;
                } catch (IndexOutOfBoundsException e) {
                    throw DukeException.DukeInvalidIndex();
                }

            case "find":
                try {
                    ArrayList<Task> matchingTasks = this.parser.findTasksByKeyword(userInput,
                            this.taskList.getTasks());
                    response = this.ui.getMatchingTasksMessage(matchingTasks);
                    return response;
                } catch (DukeException d) {
                    throw d;
                }

            default:
                Task task = this.parser.parseTaskFromUi(command, userInput);
                if (this.parser.isDuplicate(task, this.taskList.getTasks())) {
                    throw DukeException.DukeDuplicate();
                }
                response = this.taskList.addTask(task);
                writeTasks();
                return response;
            }
        } catch (DukeException d) {
             response = this.ui.getErrorMessage(d);
             return response;
        }
    }

Example from src/main/java/parser/Parser.java lines 43-93:

    public Task parseTaskFromUi(String command, String userInput) throws DukeException {
        assert command != null && userInput != null;
        switch (command) {
        case "todo":
            try {
                String description = userInput.split(" ", 2)[1];
                description = description.trim();
                if (description.equals("")) {
                    throw DukeException.DukeDescriptionEmpty();
                }
                return new Todo(description);
            } catch (IndexOutOfBoundsException e) {
                throw DukeException.DukeDescriptionEmpty();
            } catch (DukeException d) {
                throw DukeException.DukeDescriptionEmpty();
            }

        case "deadline":
            try {
                String[] descriptionAndTime = userInput.substring(9).split(" /by ");
                String description = descriptionAndTime[0].trim();
                if (description.equals("")) {
                    throw DukeException.DukeDescriptionEmpty();
                }
                LocalDate deadlineTime = parseDate(descriptionAndTime[1].trim());
                return new Deadline(description, deadlineTime);
            } catch (DukeException d) {
                throw d;
            } catch (Exception e) {
                throw DukeException.DukeInvalidCommand();
            }

        case "event":
            try {
                String[] descriptionAndTime = userInput.substring(6).split(" /at ");
                String description = descriptionAndTime[0].trim();
                if (description.equals("")) {
                    throw DukeException.DukeDescriptionEmpty();
                }
                LocalDate eventTime = parseDate(descriptionAndTime[1].trim());
                return new Event(description, eventTime);
            } catch (DukeException d) {
                throw d;
            } catch (Exception e) {
                throw DukeException.DukeInvalidCommand();
            }

        default:
            throw DukeException.DukeInvalidCommand();
        }
    }

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 40-44:

    /**
     * (Another) constructs Duke which directly parse the input to storage attribute.
     *
     * @param storage any object of IStorage class.
     */

Example from src/main/java/task/Deadline.java lines 24-29:

    /**
     * (Another) constructs Deadline.
     *
     * @param description the description for the task.
     * @param DeadlineTime deadline time for the task.
     */

Example from src/main/java/task/Event.java lines 24-29:

    /**
     * (Another) constructs Event.
     *
     * @param description the description for the task.
     * @param eventTime status of the task.
     */

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.

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.