Skip to content

Sharing iP code quality feedback [for @wucx-0] - Round 2 #1

Description

@soc-se-bot

@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/Ben.java lines 84-160:

    public String processCommand(String input) {
        try {
            Command c = Parser.parse(input);

            // For commands that need special handling in non-CLI mode
            if (c.isExit()) {
                return "Bye. Hope to see you again soon!";
            }

            // Create a mock UI to capture output
            StringBuilder output = new StringBuilder();
            UI mockUI = 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 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() {}
            };

            c.execute(tasks, mockUI, storage);
            return output.toString();

        } catch (BenException e) {
            return "OOPS!!! " + e.getMessage();
        }
    }

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

No easy-to-detect issues 👍

Aspect: Recent Git Commit Messages

possible problems in commit 701e23f:


added JavaDoc


  • Not in imperative mood (?)

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 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