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 @DesSnowy] #3

Open
soc-se-bot-blue opened this issue Sep 14, 2024 · 0 comments
Open

Sharing iP code quality feedback [for @DesSnowy] #3

soc-se-bot-blue opened this issue Sep 14, 2024 · 0 comments

Comments

@soc-se-bot-blue
Copy link

@DesSnowy 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/snowy/Snowy.java lines 27-138:

    public String getResponse(String input) {
        String result;
        Task task;

        String[] parsedInput = Parser.parse(input);
        assert parsedInput.length == 2: "Parsed length should be 2";
        String command = parsedInput[0];
        String description = parsedInput[1];

        assert command != null : "Command should not be null";
        switch (command) {
        case "bye":
            result = ui.printEnding();
            break;

        case "list":
            result = ui.printList(this.tasks);
            break;

        case "mark":
            try {
                int index = Integer.parseInt(description);
                task = tasks.markTask(index);
                assert task != null : "task should not be null";
                result = ui.printMarkDone(task);
            } catch (NumberFormatException | SnowyException e) {
                result = ui.printIndexError();
            }
            break;

        case "unmark":
            try {
                int index = Integer.parseInt(description);
                task = tasks.unmarkTask(index);
                assert task != null : "task should not be null";
                result = ui.printMarkIncomplete(task);
            } catch (NumberFormatException | SnowyException e) {
                result = ui.printIndexError();
            }
            break;

        case "todo":
            try {
                task = tasks.addToDo(description);
                assert task != null : "task should not be null";
                result = "New todo task added:\n" + task;
            } catch (SnowyException e) {
                result = ui.printTodoFormatError();
            }
            break;

        case "deadline":
            try {
                task = tasks.addDeadline(description);
                assert task != null : "task should not be null";
                result = ("New Deadline task added:\n" + task);
            } catch (SnowyException e) {
                result = ui.printDeadlineFormatError();
            }
            break;

        case "event":
            try {
                task = tasks.addEvent(description);
                assert task != null : "task should not be null";
                result = ("New Event task added:\n " + task);
            } catch (SnowyException e) {
                result = ui.printEventFormatError();
            }
            break;

        case "delete":
            try {
                int index = Integer.parseInt(description);
                task = tasks.deleteTask(index);
                assert task != null : "task should not be null";
                result = ui.printDeleteTask(task);
            } catch (NumberFormatException | SnowyException e) {
                result = "Invalid index format. Please try again";
            }
            break;

        case "find":
            ArrayList<Task> foundTasks = tasks.findTask(description);
            result = ui.printFoundTask(foundTasks);
            break;

        case "hello":
            result = ui.printGreeting();
            break;

        case "snooze":
            try {
                task = tasks.changeDate(description);
                result = ui.printDateChange(task);
            } catch (NumberFormatException |SnowyException e) {
                result = ui.printChangeDateError(e.getMessage());
            }
            break;

        default:
            result = ui.printUnknownCommand();
            break;
        }

        try {
            storage.save(tasks.toSaveString());
        } catch (SnowyException e) {
            result = ui.printUpdateError();
        }
        return result;
    }

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/snowy/Storage.java lines 50-54:

    /**
     * Write into the file with the specified String.
     * @param saveLines the lines to be saved into the file.
     * @throws SnowyException if the file is unable to be updated.
     */

Example from src/main/java/snowy/Task.java lines 35-38:

    /**
     * Convert the task into a String that will be saved into a file.
     * @return the String that represents the task when saved.
     */

Example from src/main/java/snowy/TaskList.java lines 213-217:

    /**
     * Find all task which description matches the specifed string before returning them in an arrayList.
     * @param description The String to be matched.
     * @return An ArrayList of tasks which matches the string
     */

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 👍


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