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

Open
soc-se-script opened this issue Feb 17, 2024 · 0 comments
Open

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

soc-se-script opened this issue Feb 17, 2024 · 0 comments

Comments

@soc-se-script
Copy link

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

Example from src/main/java/Duke.java lines 22-22:

        boolean exitFlag = false;

Example from src/main/java/Duke.java lines 111-111:

                    boolean successFlag = false;

Example from src/main/java/list_Entry.java lines 8-8:

    protected boolean check;

Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)

Aspect: Brace Style

No easy-to-detect issues 👍

Aspect: Package Name Style

No easy-to-detect issues 👍

Aspect: Class Name Style

Example from src/main/java/list_Entry.java lines 1-1:

public class list_Entry {

Example from src/main/java/list_Entry_Deadline.java lines 1-1:

public class list_Entry_Deadline extends list_Entry {

Example from src/main/java/list_Entry_Event.java lines 1-1:

public class list_Entry_Event extends list_Entry {

Suggestion: Follow the class naming convention specified by the coding standard.

Aspect: Dead Code

Example from src/main/java/Duke.java lines 44-44:

//                        break;

Example from src/main/java/Duke.java lines 47-47:

//                        break;

Example from src/main/java/Duke.java lines 198-198:

//                output = new String(output + "      " + readText + "\n");

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/Duke.java lines 17-153:

    public static void main(String[] args) throws Exception{

        String NAME = "Luna"; // TENTATIVE
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        bot_functions.shifted_print(bot_functions.greetingString(NAME));
        boolean exitFlag = false;
        commandHints currentHint = commandHints.EXIT;
        ArrayList<list_Entry> user_list = new ArrayList<>();

        while (!exitFlag) {
            String input_command = br.readLine();
            if (input_command.equalsIgnoreCase("help")) {
                switch(currentHint) {
                    case LIST:
                        bot_functions.shifted_print("To display all the task in your list\n--> Type: list");
                        break;
                    case TODO:
                        bot_functions.shifted_print("To add a to-do task to your list\n--> Type: todo <task name>");
                        break;
                    case DEADLINE:
                        bot_functions.shifted_print("To add a deadline task to your list\n--> Type: deadline <task name> <end date>");
                        break;
                    case EVENT:
                        bot_functions.shifted_print("To add a event task to your list\n--> Type: event <task name> <start date> <end date>");
                        break;
                    case MARK:
                        bot_functions.shifted_print("To mark a task as done\n--> Type: mark <list num>");
//                        break;
//                    case UNMARK:
                        bot_functions.shifted_print("To unmark a task as not done\n--> Type: unmark <list num>");
//                        break;
//                    case DELETE:
                        bot_functions.shifted_print("To delete a task from the list\n--> Type: delete <list num>");
                        break;
                    case EXIT:
                        bot_functions.shifted_print("End the program :(\n--> Type: bye");
                        break;

                }
            }
            // IF EXIT
            if (input_command.equalsIgnoreCase("bye") || input_command.equalsIgnoreCase("exit")) {
                bot_functions.shifted_print(bot_functions.signoffString());
                exitFlag = true;

            // IF LIST IS REQUESTED
            } else if (input_command.equalsIgnoreCase("list")){
                currentHint = commandHints.LIST;

                StringBuilder text = new StringBuilder();
                if (user_list.isEmpty()) {
                    text.append("List is Empty");
                } else {
                    text.append("These are your outstanding tasks\n");
                    for (int i = 0; i < user_list.size(); i++) {
                        list_Entry ent = user_list.get(i);
                        text.append((i+1)).append(".").append(ent.toString()).append("\n");
                    }
                }
                bot_functions.shifted_print(text.toString());

            } else {
                currentHint = commandHints.MARK;

                String [] keys = input_command.split(" ", 2);

                if (keys[0].equalsIgnoreCase("unmark") || keys[0].equalsIgnoreCase("mark") || keys[0].equalsIgnoreCase("delete")) {
                    if (Arrays.asList(keys).size() < 2) {
                        bot_functions.shifted_print("Missing inputs");
                    } else if (!bot_functions.isNumeric(keys[1])) {
                        bot_functions.shifted_print("Please input a number after the command E.g (mark/unmark/delete) 3");
                    } else {
                        int pos = Integer.parseInt(keys[1]);
                        if (pos <= user_list.size() && pos > 0) {
                            list_Entry ent = user_list.get(pos-1);
                            if (keys[0].equalsIgnoreCase("delete")) {
                                user_list.remove(pos-1);
                                bot_functions.shifted_print("Deleting the following task:\n " + ent
                                        + "\nThere are " + user_list.size() + " tasks in the list");
                            }
                            else if (keys[0].equalsIgnoreCase("mark")) {
                                ent.markEntry();
                                bot_functions.shifted_print("Nice! I've marked this task as done:\n" + ent);
                            } else {
                                ent.unmarkEntry();
                                bot_functions.shifted_print("Nice! I've marked this task as not done yet:\n" + ent);
                            }
                        } else {
                            bot_functions.shifted_print("There are " + user_list.size() + " tasks in the list");
                        }
                    }
                } else {
                    currentHint = commandHints.TODO;

                    boolean successFlag = false;
                    list_Entry ent = new list_Entry();
                    if (Arrays.asList(keys).size() == 2) {
                        if (keys[0].equalsIgnoreCase("todo")) {
                            successFlag = true;
                            ent = new list_Entry_Todo(keys[1], false);
                        } else if (keys[0].equalsIgnoreCase("deadline")) {
                            currentHint = commandHints.DEADLINE;

                            String[] keys_entry = keys[1].split(" /by ", 2);
                            if (Arrays.asList(keys_entry).size() == 2) {
                                successFlag = true;
                                ent = new list_Entry_Deadline(keys_entry[0], false, keys_entry[1]);
                            }
                        } else if (keys[0].equalsIgnoreCase("event")) {
                            currentHint = commandHints.EVENT;

                            String[] keys_entry1 = keys[1].split(" /from ", 2);
                            if (Arrays.asList(keys_entry1).size() == 2) {
                                String[] keys_entry2 = keys_entry1[1].split(" /to ", 2);
                                if (Arrays.asList(keys_entry2).size() == 2) {
                                    successFlag = true;
                                    ent = new list_Entry_Event(keys_entry1[0], false, keys_entry2[0], keys_entry2[1]);
                                }
                            }
                        }
                    }

                    if (successFlag) {
                        user_list.add(ent);
                        StringBuilder text = new StringBuilder();
                        String count_msg = "okie! Added a task to the list:\n   " + ent + "\nNow you have " + user_list.size() + " tasks in the list.";
                        text.append(count_msg);
                        bot_functions.shifted_print(text.toString());
                    } else {
                        bot_functions.shifted_print("Wrong format");
                    }

                }
            }
        }
        System.exit(0);
    }

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

possible problems in commit 0a71c2c:


A-TextUITesting - Completed

(Use for providing hints for correct command syntax)


  • Not in imperative mood (?)

possible problems in commit ebe13f5:


A-TextUITesting - Completed

(Use for providing hints for correct command syntax)


  • Not in imperative mood (?)

possible problems in commit 06ea13b:


Level 5 - Completed
--> Same as Level 4
--> already have some error handling
--> can come back to stretch goals)
(different types of errors)
No Warnings! (typos tho)


  • No blank line between subject and body

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