Skip to content

Sharing iP code quality feedback [for @ong6] #8

Description

@nus-se-bot

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 code further.

IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most one example is given i.e., there can be other areas/places to improve.

Aspect: Tab Usage

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/duke/Parser.java lines 41-97:

    private String identifyInput(String input) throws DukeGeneralException, DukeTaskException, IOException {
        Task temp;
        String output;
        switch (getCommand(input)) {
        case "bye":
            try {
                storage.save(tasks);
            } catch (IOException e) {
                return duke.Ui.showLoadingError();
            }
            output = duke.Ui.showBye();
            break;
        case "list":
            if (tasks.isEmpty()) {
                return duke.Ui.showDukeEmptyListError();
            }
            output = duke.Ui.showList(tasks);
            break;
        case "find":
            output = duke.Ui.showFind(tasks, getMessage(input).trim());
            break;
        case "done":
            tasks.setDone(duke.Ui.getIndex(input));
            output = duke.Ui.showDone(input, tasks);
            break;
        case "todo":
            temp = new ToDo(getMessage(input));
            output = duke.Ui.showTaskAdded(tasks, temp);
            tasks.add(temp);
            break;
        case "deadline":
            temp = new Deadline(getMessage(input));
            output = duke.Ui.showTaskAdded(tasks, temp);
            tasks.add(temp);
            break;
        case "event":
            temp = new Event(getMessage(input));
            output = duke.Ui.showTaskAdded(tasks, temp);
            tasks.add(temp);
            break;
        case "delete":
            output = duke.Ui.showDeleteTask(input, tasks);
            tasks.remove(duke.Ui.getIndex(input));
            break;
        case " ":
            output = duke.Ui.showEmptyError();
            break;
        case "archive":
            String archivePath = getMessage(input).trim();
            output = duke.Ui.showArchiveTasks(tasks, archivePath);
            storage.archive(tasks, archivePath);
            break;
        default:
            throw new DukeGeneralException("");
        }
        return output;
    }

Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods. You may ignore this suggestion if you think a longer method is justified in a particular case.

ℹ️ The bot account @cs2103-bot 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