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 @Ty-stan0417] - Round 2 #4

Open
nus-se-script opened this issue Mar 19, 2024 · 0 comments
Open

Comments

@nus-se-script
Copy link

@Ty-stan0417 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/tyler/parser/Parser.java lines 38-118:

    public static Command parse(String line) throws TylerException {
        String[] input = line.split(" ");
        String command = input[0];
        switch (command) {
        case "bye":
            return new ExitCommand();
        case "list":
            return new ListCommand();
        case "mark": {
            if (input.length < 2) {
                throw new InvalidTaskException();
            }
            int index = Integer.parseInt(input[1]);
            return new MarkCommand(index);
        }
        case "unmark": {
            if (input.length < 2) {
                throw new InvalidTaskException();
            }
            int index = Integer.parseInt(input[1]);
            return new UnmarkCommand(index);
        }
        case "todo": {
            if (input.length < 2) {
                throw new EmptyNameException();
            }
            String name = line.split(" ", 2)[1];
            return new TodoCommand(name);
        }
        case "deadline": {
            try {
                if (input.length < 2) {
                    throw new EmptyNameException();
                }
                String[] info = line.split(" ", 2)[1].split("/by ");
                String name = info[0];
                LocalDateTime end = LocalDateTime.parse(info[1], INPUT_DATE_FORMAT);
                return new DeadlineCommand(name, end);
            } catch (DateTimeParseException e) {
                throw new InvalidDateTimeFormatException();
            } catch (IndexOutOfBoundsException e) {
                throw new WrongInputFormatException();
            }
        }
        case "event": {
            try {
                if (input.length < 2) {
                    throw new EmptyNameException();
                }
                String[] info = line.split(" ", 2)[1].split("/from ");
                String name = info[0];
                String[] startToEnd = info[1].split(" /to ");
                LocalDateTime start = LocalDateTime.parse(startToEnd[0], INPUT_DATE_FORMAT);
                LocalDateTime end = LocalDateTime.parse(startToEnd[1], INPUT_DATE_FORMAT);
                return new EventCommand(name, start, end);
            } catch (DateTimeParseException e) {
                throw new InvalidDateTimeFormatException();
            } catch (IndexOutOfBoundsException e) {
                throw new WrongInputFormatException();
            }
        }
        case "delete": {
            if (input.length < 2) {
                throw new InvalidTaskException();
            }
            int index = Integer.parseInt(input[1]);
            return new DeleteCommand(index);
        }
        case "find": {
            if (input.length < 2) {
                throw new EmptyNameException();
            }
            String name = line.split(" ", 2)[1];
            return new FindCommand(name);
        }
        case "help":
            return new HelpCommand();
        default:
            throw new UndefinedActionException();
        }
    }

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/tyler/Tyler.java lines 37-42:

    /**
     * Get response from the String input to the UI.
     *
     * @param input The input to get response.
     * @return A String representation of the input command, what input doing.
     */

Example from src/main/java/tyler/parser/Parser.java lines 31-37:

    /**
     * Parse the line from System.in to a Command.
     *
     * @param line            The line needed to be parsed.
     * @return                A specific command from command class.
     * @throws TylerException May have name:null, invalid action, index:null
     */

Example from src/main/java/tyler/storage/Storage.java lines 30-35:

    /**
     * Load the task list from local given specific file path to the chatbot.
     *
     * @return             A Task ArrayList.
     * @throws IOException The file or directory may not exist.
     */

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

possible problems in commit e431863:


Provide in-App guidance to users.

Add InvalidDateTimeFormatException which throws error when the date
format is not correct.

Add WrongInputFormatException. Throws error when deadline and event
command does not follow the format.


  • Subject line should not end with a period

possible problems in commit c72fa49:


Add assert feature to some parts of the code.


  • Subject line should not end with a period

Suggestion: Follow the given conventions for Git commit messages for future commits (do not modify past commit messages as doing so will change the commit timestamp that we used to detect your commit timings).

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