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

Open
nus-se-bot opened this issue Sep 11, 2021 · 0 comments
Open

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

nus-se-bot opened this issue Sep 11, 2021 · 0 comments

Comments

@nus-se-bot
Copy link

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 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/nyx/Parser.java lines 24-73:

    public static Command parse(String input) throws NyxException {
        String[] splitInput = input.split(" ", 2);
        String keyword = splitInput[0].toLowerCase();
        String information = "";
        if (splitInput.length > 1) {
            information = splitInput[1].strip();
        }

        switch (keyword) {
        case "list":
            return new ListCommand();
        case "done":
            if (information.isEmpty()) {
                DoneCommand.throwEmptyException();
            }
            return new DoneCommand(information);
        case "todo":
            if (information.isEmpty()) {
                ToDoCommand.throwEmptyException();
            }
            return new ToDoCommand(information);
        case "deadline":
            if (information.isEmpty()) {
                DeadlineCommand.throwEmptyException();
            }
            return new DeadlineCommand(information);
        case "event":
            if (information.isEmpty()) {
                EventCommand.throwEmptyException();
            }
            return new EventCommand(information);
        case "delete":
            if (information.isEmpty()) {
                DeleteCommand.throwEmptyException();
            }
            return new DeleteCommand(information);
        case "find":
            if (information.isEmpty()) {
                FindCommand.throwEmptyException();
            }
            return new FindCommand(information);
        case "update":
            if (information.isEmpty()) {
                UpdateCommand.throwEmptyException();
            }
            return new UpdateCommand(information);
        default:
            throw new NyxException("I dont understand this command... Please try again.");
        }
    }

Example from src/main/java/nyx/command/UpdateCommand.java lines 19-61:

    public String execute(TaskList taskList, Storage storage) throws NyxException {
        String[] splitInfo = information.split(" ", 2);
        assert splitInfo.length > 0 : "Update information not read in correctly";

        try {
            int index = Integer.parseInt(splitInfo[0]) - 1;

            if (taskList.getNumTasks() == 0) {
                return "No task to delete!";
            }

            Task task = taskList.getTask(index);

            if (task instanceof ToDo) {
                task.updateContent(splitInfo[1]);
            } else if (task instanceof Deadline) {
                String[] secondInfo = splitInfo[1].split(" /by ");
                if (secondInfo.length != 2) {
                    throw new NyxException("You need to update deadline using the following format:"
                            + "\n{ details } /by { datetime }");
                }
                task.updateContent(secondInfo[0]);
                Deadline deadline = (Deadline) task;
                deadline.changeDateTime(secondInfo[1]);
            } else {
                String[] secondInfo = splitInfo[1].split(" /at ");
                if (secondInfo.length != 2) {
                    throw new NyxException("You need to update event using the following format:"
                            + "\n{ details } /at { datetime }");
                }
                task.updateContent(secondInfo[0]);
                Event event = (Event) task;
                event.changeDateTime(secondInfo[1]);
            }
            storage.overwriteData(taskList);

            return String.format("Noted! I've update this task to:\n  %s", task);
        } catch (IndexOutOfBoundsException | NumberFormatException e) {
            throw new NyxException("Invalid task index!");
        } catch (IOException e) {
            throw new NyxException("Unable to save the changes...");
        }
    }

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.

Aspect: Header Comments

Example from src/main/java/nyx/task/Task.java lines 39-41:

    /**
     * Mark task 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 (Subject Only)

No easy-to-detect issues 👍

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