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 @nerdyboy98] #1

Open
soc-se-bot-blue opened this issue Feb 11, 2023 · 0 comments
Open

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

soc-se-bot-blue opened this issue Feb 11, 2023 · 0 comments

Comments

@soc-se-bot-blue
Copy link

@nerdyboy98 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

Example from src/main/java/duke/Duke.java lines 45-45:

        //System.out.println(greetings);

Example from src/main/java/duke/Duke.java lines 62-62:

        //this.parser.parse(userInput);

Example from src/main/java/duke/Duke.java lines 64-64:

        //return "lol";

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/duke/Parser.java lines 33-89:

    public String parse(String userMessage) {
        String [] parts = userMessage.split(" ", 2);

        if (parts[0].equals("bye")) {
            return bye();
        } else if (parts[0].equals("list")) {
            return list();
        } else if (parts[0].equals("mark")) {
            return mark(userMessage);
        } else if (parts[0].equals("unmark")) {
            return unmark(userMessage);
        } else if (parts[0].equals("delete")) {
            return delete(userMessage);
        } else if (parts[0].equals("todo")) {
            try {
                Todo newToDo = new Todo(parts[1]);
                return this.taskList.add(newToDo);
            } catch (IndexOutOfBoundsException e) {
                return "Bruhh.. The description of todo cannot be empty.";
            }
        } else if (parts[0].equals("deadline")) {
            try {
                String[] deadlineParts = parts[1].split(" /");
                String[] deadline = deadlineParts[1].split(" ", 2);
                LocalDate byDate = LocalDate.parse(deadline[1]);
                Deadline newDeadline = new Deadline(deadlineParts[0], byDate);
                return this.taskList.add(newDeadline);
            } catch (IndexOutOfBoundsException e) {
                return "Bruhh.. The description of deadline cannot be empty.";
            } catch (DateTimeParseException e) {
                return "Incorrect date format dude.. try again~";
            }
        } else if (parts[0].equals("event")) {
            try {
                String[] eventParts = parts[1].split(" /");
                String[] from = eventParts[1].split(" ", 2);
                String[] to = eventParts[2].split(" ", 2);
                LocalDate fromDate = LocalDate.parse(from[1]);
                LocalDate toDate = LocalDate.parse(to[1]);
                Event newEvent = new Event(eventParts[0], fromDate, toDate);
                return this.taskList.add(newEvent);
            } catch (IndexOutOfBoundsException e) {
                return "Bruhh.. The description of event cannot be empty.";
            } catch (DateTimeParseException e) {
                return "Incorrect date format dude.. try again~";
            }
        } else if (parts[0].equals("find")) {
            try {
                String keyword = parts[1];
                return this.taskList.find(keyword);
            } catch (IndexOutOfBoundsException e) {
                return "Bruhh.. You gotta tell me what to search for :<";
            }
        } else {
            return "I have no idea what are you talking about dude..";
        }
    }

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

No easy-to-detect issues 👍

Aspect: Recent Git Commit Message (Subject Only)

possible problems in commit 22d5006:

Changed layout to comply with coding standards

  • 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