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 @wesho1107] - Round 2 #5

Open
soc-se-bot opened this issue Oct 16, 2023 · 0 comments
Open

Sharing iP code quality feedback [for @wesho1107] - Round 2 #5

soc-se-bot opened this issue Oct 16, 2023 · 0 comments

Comments

@soc-se-bot
Copy link

@wesho1107 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 5-5:

    private boolean markedStatus;

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

    private boolean reminderStatus = 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

No easy-to-detect issues 👍

Aspect: Method Length

Example from src/main/java/duke/main/Parser.java lines 21-105:

    public static Command parse(String fullCommand) throws DukeException {
        String[] splitCommand = fullCommand.split(" ", 2);
        String headCommand = splitCommand[0];
        String commandDetails;

        if (headCommand.equals("bye")) {
            return new ExitCommand(null);
        }

        if (headCommand.equals("list")) {
            return new ListCommand(null);
        }

        if (headCommand.equals("reminder")) {
            return new ReminderCommand(null);
        }

        if (headCommand.equals("help")) {
            return new HelpCommand(null);
        }

        if (splitCommand.length < 2) {
            throw new EmptyTaskException();
        }

        commandDetails = splitCommand[1];
        String task;
        String[] details;
        int index;

        switch(headCommand) {
        case "delete":
            index = Integer.parseInt(commandDetails) - 1;
            return new DeleteCommand(index);

        case "mark":
            index = Integer.parseInt(commandDetails) - 1;
            return new MarkCommand(index, true);

        case "unmark":
            index = Integer.parseInt(commandDetails) - 1;
            return new MarkCommand(index, false);

        case "remind":
            index = Integer.parseInt(commandDetails) - 1;
            return new RemindCommand(index);

        case "find":
            return new FindCommand(commandDetails);

        case "todo":
            task = commandDetails;
            Todo todo = new Todo(task, false, false);
            return new AddCommand(todo);

        case "deadline":
            details = commandDetails.split(" /by ");
            if (details.length < 2) {
                throw new NoDueDateException();
            }
            task = details[0];
            String duedate = details[1];
            Deadline deadline = new Deadline(task, duedate, false, false);
            return new AddCommand(deadline);

        case "event":
            details = commandDetails.split(" /from ");
            if(details.length < 2) {
                throw new NoEventStartException();
            }
            task = details[0];
            String[] timeDetails = details[1].split(" /to ");
            if(timeDetails.length < 2) {
                throw new NoEventEndException();
            }
            String start = timeDetails[0];
            String end = timeDetails[1];
            Event event = new Event(task, start, end, false, false);
            return new AddCommand(event);

        default:
            throw new DukeException("    TWEET!!! No such 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/main/Storage.java lines 83-88:

    /**
     * Update the file with a list of tasks, for when deleting or marking.
     *
     * @param tasks The list of tasks to be saved to the file.
     * @throws IOException If there's an error while writing to the file.
     */

Example from src/main/java/duke/main/TaskList.java lines 72-76:

    /**
     * Retrieve the number of tasks in the TaskList.
     *
     * @return The number of tasks in the TaskList.
     */

Example from src/main/java/duke/main/TaskList.java lines 91-95:

    /**
     * Retrieve a list of reminders from the TaskList.
     *
     * @return A list of tasks that are reminders and not marked as done.
     */

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 cs2103@comp.nus.edu.sg 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