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

Open
soc-se-bot opened this issue Sep 10, 2022 · 0 comments
Open

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

soc-se-bot opened this issue Sep 10, 2022 · 0 comments

Comments

@soc-se-bot
Copy link

@dlimyy 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 36-79:

    public static Command parse(String command, TaskList taskList) throws DukeException,
            DateTimeParseException, NumberFormatException{
        String lowercaseCommand = command.toLowerCase();
        if (lowercaseCommand.equals("bye")) {
            return new ByeCommand();
        }
        if (lowercaseCommand.equals("list")) {
            return new ListCommand();
        }
        if (lowercaseCommand.startsWith("mark")) {
            int position = parseMarkedTask(command, taskList);
            return new MarkCommand(position);
        }
        if (lowercaseCommand.startsWith("unmark")) {
            int position = parseUnmarkedTask(command, taskList);
            return new UnmarkCommand(position);
        }
        if (lowercaseCommand.startsWith("todo")) {
            String description = parseToDo(command);
            return new ToDoCommand(description);
        }
        if (lowercaseCommand.startsWith("undo")) {
            return new UndoCommand();
        }
        if (lowercaseCommand.startsWith("deadline")) {
           String[] taskWithDeadline = parseDeadline(command);
           LocalDate date = parseDate(taskWithDeadline[1]);
           return new DeadlineCommand(taskWithDeadline[0], date);
        }
        if (lowercaseCommand.startsWith("event")) {
            String[] taskWithPeriod = parseEvent(command);
            LocalDate date = parseDate(taskWithPeriod[1]);
            return new EventCommand(taskWithPeriod[0], date);
        }
        if (lowercaseCommand.startsWith("delete")) {
            int position = parseDelete(command, taskList);
            return new DeleteCommand(position);
        }
        if (lowercaseCommand.startsWith("find")) {
            String keyword = parseFind(command);
            return new FindCommand(keyword);
        }
        return new WrongCommand();
    }

Example from src/main/java/duke/Storage.java lines 29-66:

    public ArrayList<Task> readFile() throws IOException {
        ArrayList<Task> dukeBotArray  = new ArrayList<>();
        File dataDirectory = new File("Info");
        if (!dataDirectory.isDirectory()) {
            dataDirectory.mkdir();
        }
        File dataFile = new File("Info/data.txt");
        dataFile.createNewFile();
        Scanner scanningFile = new Scanner(dataFile);
        while (scanningFile.hasNext()) {
            String currLine = scanningFile.nextLine();
            String[] task = currLine.split(" # ");
            if (task.length == 3) {
                ToDo todo = new ToDo(task[2]);
                boolean isMarked = task[1].equals("T");
                todo.setCompleted(isMarked);
                dukeBotArray.add(todo);
            }
            if (task.length == 4) {
                if (task[0].equals("D")) {
                    LocalDate currDate = LocalDate.parse(task[3]);
                    Deadline deadline = new Deadline(task[2],currDate);
                    boolean isMarked = task[1].equals("T");
                    deadline.setCompleted(isMarked);
                    dukeBotArray.add(deadline);
                }
                if (task[0].equals("E")) {
                    LocalDate currDate = LocalDate.parse(task[3]);
                    Event event = new Event(task[2],currDate);
                    boolean isMarked = task[1].equals("T");
                    event.setCompleted(isMarked);
                    dukeBotArray.add(event);
                }
            }
        }
        scanningFile.close();
        return dukeBotArray;
    }

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/Ui.java lines 58-62:

    /**
     * Return the message for the exception.
     * @param message The message for the exception.
     * @return The message for the exception.
     */

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)

possible problems in commit 549e06f:

Added Undo Feature

  • Not in imperative mood (?)

Suggestion: Follow the given conventions for Git commit messages for future commits (no need to modify past commit messages).

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