Skip to content

Sharing iP code quality feedback [for @wucx-0] - Round 3 #5

Description

@soc-se-bot-red

@wucx-0 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/ben/parser/Parser.java lines 29-95:

    public static Command parse(String fullCommand) throws BenException {
        if (fullCommand == null || fullCommand.trim().isEmpty()) {
            throw new BenException("Enter a ben.command!");
        }

        assert fullCommand != null : "Command should not be null after null check";

        String command = fullCommand.trim();
        String[] parts = command.split("\\s+", 2); // Split into ben.command and arguments
        String commandWord = parts[0].toLowerCase();
        String arguments = parts.length > 1 ? parts[1] : "";

        assert parts.length >= 1 : "Split command should have at least one part";

        switch (commandWord) {
            case "bye":
                return new ExitCommand();

            case "list":
                return new ListCommand();

            case "mark":
                return new MarkCommand(arguments, true);

            case "unmark":
                return new MarkCommand(arguments, false);

            case "delete":
                return new DeleteCommand(arguments);

            case "todo":
                if (arguments.isEmpty()) {
                    throw new BenException("The description cannot be empty! Please specify what you want to todo.");
                }
                return new AddCommand("todo", arguments);

            case "deadline":
                if (arguments.isEmpty()) {
                    throw new BenException("The description cannot be empty! Please specify what you want to deadline.");
                }
                return new AddCommand("deadline", arguments);

            case "event":
                if (arguments.isEmpty()) {
                    throw new BenException("The description cannot be empty! Please specify what you want to event.");
                }
                return new AddCommand("event", arguments);

            case "due":
                return new DueCommand(arguments);

            case "find":
                if (arguments.isEmpty()) {
                    throw new BenException("Please specify a keyword to search for! Format: find <keyword>");
                }
                return new FindCommand(arguments);

            case "snooze":
                if (arguments.isEmpty()) {
                    throw new BenException("Please specify which task to snooze! Format: snooze <task_number> <new_date> or snooze <task_number> +<days>");
                }
                return new SnoozeCommand(arguments);

            default:
                throw new BenException("I'm sorry, say that again?");
        }
    }

Example from src/main/java/ben/gui/GUI.java lines 135-201:

    private UI createMockUI(StringBuilder output) {
        return new UI() {
            @Override
            public void showMessage(String message) {
                output.append(message);
            }

            @Override
            public void showTaskList(TaskList tasks) {
                output.append(tasks.toString());
            }

            @Override
            public void showTaskAdded(Task task, int totalTasks) {
                output.append("Got it. I've added this task:\n   ")
                        .append(task)
                        .append("\nNow you have ")
                        .append(totalTasks)
                        .append(" tasks in the list.");
            }

            @Override
            public void showTaskDeleted(Task task, int remainingTasks) {
                output.append("Noted. I've removed this task:\n   ")
                        .append(task)
                        .append("\nNow you have ")
                        .append(remainingTasks)
                        .append(" tasks in the list.");
            }

            @Override
            public void showTaskMarkedDone(Task task) {
                output.append("Nice! I've marked this task as done:\n   ")
                        .append(task);
            }

            @Override
            public void showTaskMarkedNotDone(Task task) {
                output.append("OK, I've marked this task as not done yet:\n   ")
                        .append(task);
            }

            @Override
            public void showTaskSnoozed(Task originalTask, Task snoozedTask) {
                output.append("Got it! I've snoozed this task:\n")
                        .append("   From: ").append(originalTask).append("\n")
                        .append("   To:   ").append(snoozedTask);
            }

            @Override
            public void showError(String errorMessage) {
                output.append("OOPS!!! ").append(errorMessage);
            }

            // Unused methods for mock UI
            @Override
            public void showWelcome(String name) {}
            @Override
            public void showGoodbye() {}
            @Override
            public void showLine() {}
            @Override
            public String readCommand() { return ""; }
            @Override
            public void close() {}
        };
    }

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/ben/command/SnoozeCommand.java lines 108-110:

    /**
     * Simple event snooze - moves both start and end times, preserving duration
     */

Example from src/main/java/ben/command/SnoozeCommand.java lines 144-146:

    /**
     * Event snooze with modifier - handles /start, /duration, or direct time specification
     */

Example from src/main/java/ben/command/SnoozeCommand.java lines 170-173:

    /**
     * Advanced event snooze - handles separate start/end times or /from modifier
     * AI is used to assist the creation of more command line argument involving cmd.
     */

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 Messages

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions