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 check results [for @Zhilin-Huang] #1

Open
nus-pe-script opened this issue Feb 23, 2020 · 0 comments
Open

Sharing iP code quality check results [for @Zhilin-Huang] #1

nus-pe-script opened this issue Feb 23, 2020 · 0 comments

Comments

@nus-pe-script
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 one example is given i.e., there can be other areas/places to improve.

Aspect: Tab Usage

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/chatty/ChattyChatBot.java line 27:

    public static void main(String[] args) {
        sendWelcomeMessage();

        List<Task> tasks = new ArrayList<>();

        readDataFromFile(tasks);
        System.out.println(LINE_BREAK);

        String userInput;
        do {
            userInput = SCANNER.nextLine();

            System.out.println(LINE_BREAK);

            // Solution below adapted from: https://stackoverflow
            // .com/questions/5067942/what-is-the-best-way-to-extract-the-first-word-from-a-string-in-java
            String[] array = userInput.split(SPACE_SEPARATOR, 2);
            String action = array[0];

            switch (action) {
            case LIST_STRING:
                listAllTasks(tasks);
                break;
            case DONE_STRING:
                try {
                    markTaskAsDone(tasks, array[1]);
                } catch (ArrayIndexOutOfBoundsException e) {
                    System.out.println("Let me know which task you would like to mark as done?");
                }
                break;
            case TODO_STRING:
                try {
                    addToDoTask(tasks, array[1]);
                } catch (ArrayIndexOutOfBoundsException e) {
                    System.out.println("Sure, let me know what ToDo task you would like to add!");
                }
                break;
            case DEADLINE_STRING:
                try {
                    addDeadlineTask(tasks, array[1]);
                } catch (ArrayIndexOutOfBoundsException e) {
                    System.out.println("Sure, let me know what Deadline task you would like to add!");
                } catch (ChattyChatBotException e) {
                    System.out.println("Please specify the deadline of your task");
                }
                break;
            case EVENT_STRING:
                try {
                    addEventTask(tasks, array[1]);
                } catch (ArrayIndexOutOfBoundsException e) {
                    System.out.println("Sure, let me know what Event task you would like to add!");
                } catch (ChattyChatBotException e) {
                    System.out.println("Please specify the time of your event");
                }
                break;
            case DELETE_STRING:
                try {
                    deleteTask(tasks, array[1]);
                } catch (ArrayIndexOutOfBoundsException e) {
                    System.out.println("Let me know which task you would like to delete?");
                }
                break;
            case BYE_STRING:
                saveDataToFile(tasks);
                sendByeMessage();
                break;
            default:
                sendDefaultResponse();
            }

            System.out.println(LINE_BREAK);
        } while (!userInput.equals(BYE_STRING));
    }

Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods.

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