Skip to content

Sharing iP code quality feedback [for @AerollingOverDeepBlueSeas] #1

@soc-se-bot

Description

@soc-se-bot

@AerollingOverDeepBlueSeas 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/duke/Parser.java lines 51-139:

    public void parseCommand(String input, TaskList tasks, Storage storage) throws TeteException {
        Command command;
        String[] inputs = input.split(" ");

        // Validating command keyword
        try {
            command = Command.valueOf(inputs[0].toUpperCase());
        } catch (IllegalArgumentException e) {
            throw new InvalidCommandException();
        }

        switch (command) {
        case LIST:
            tasks.displayItems();
            break;
        case MARK:
            tasks.markItem(inputs[1]);
            break;
        case UNMARK:
            tasks.unmarkItem(inputs[1]);
            break;
        case DELETE:
            if (inputs.length == 2) {
                tasks.removeItem(inputs[1]);
            } else {
                throw new EmptyDeleteException();
            }
            break;
        case TODO:
            if (inputs.length > 1) {
                tasks.addItem(new Todo(input.replaceFirst("todo ", "")));
            } else {
                throw new EmptyTodoException();
            }
            break;
        case DEADLINE:
            if (inputs.length > 1) {
                if (input.contains(" /by ")) {
                    String[] temp = input.replaceFirst("deadline ", "").split(" /by ");
                    LocalDate by = Parser.validateDate(temp[1]);
                    tasks.addItem(new Deadline(temp[0], by));
                } else {
                    if (input.contains("/by")) {
                        throw new MissingFieldContentsException("/by");
                    } else {
                        throw new MissingFieldException("/by");
                    }
                }
            } else {
                throw new EmptyDeadlineException();
            }
            break;
        case EVENT:
            if (inputs.length > 1) {
                if (input.contains(" /from ") && input.contains(" /to ")) {
                    String[] temp = input.replaceFirst("event ", "")
                            .replaceFirst(" /from ", "---")
                            .replaceFirst(" /to ", "---")
                            .split("---");
                    if (temp.length == 3) {
                        LocalDate from = Parser.validateDate(temp[1]);
                        LocalDate to = Parser.validateDate(temp[2]);
                        tasks.addItem(new Event(temp[0], from, to));
                    } else {
                        throw new MissingFieldContentsException("/from and/or /to");
                    }
                } else {
                    if (input.contains(" /to")) {
                        throw new MissingFieldContentsException("/to");
                    } else {
                        throw new MissingFieldException("/from and/or /to");
                    }
                }
            } else {
                throw new EmptyEventException();
            }
        case FIND:
            tasks.findAndDisplay(inputs[1]);
            break;
        case BYE:
            try {
                storage.saveAndClose(tasks.convertToDataList());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            break;
        }

    }

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/duke/Storage.java lines 43-47:

    /**
     * Return contents already stored in the file on opening.
     *
     * @return contents stored in file as ArrayList of String.
     */

Example from src/main/java/duke/Parser.java lines 43-50:

    /**
     * Processes, validates and executes commands.
     *
     * @param input from user, which may contain a valid command.
     * @param tasks for commands involving the current list of tasks.
     * @param storage for commands involving file operations.
     * @throws TeteException if command is invalid or other exceptions are encountered when executing a valid command.
     */

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

possible problems in commit 13ec63f:


Updated Level-9 so find is more flexible (description only needs to contain the search string, instead of exact match). Enforced OOP better by moving more display calls to UI.


  • Not in imperative mood (?)
  • Longer than 72 characters
  • Subject line should not end with a period

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 👍


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

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