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

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

Sharing iP code quality check results [for @nguan1] #1

nus-pe-script opened this issue Feb 24, 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/duke/Parser.java line 9:

    public static void parseCommand(String command, TaskList tasks) {
        /**
         * This method processes the command by the user and executes them
         *
         * @param command The command that the user specified
         * @param tasks list of tasks that the command will be executed upon
         */

        if (command.equals("list")){
            listCommand(tasks);
        } else if (command.startsWith("done")){
            doneCommand(command,tasks);
        } else if (command.equals("bye")){
            try {
                Storage.writeToFile("./duke.txt",tasks);
            } catch (IOException e) {
                System.out.println("Error writing to file");
            }
            System.out.println("Bye. Hope to see you again soon! :)");
            System.exit(0);
        } else {
            String[] splitString = command.split(" ", 2);
            if (splitString[0].equals("deadline")){
                deadlineCommand(splitString,tasks);
            } else if (splitString[0].equals("todo")){
                todoCommand(splitString,tasks);
            } else if (splitString[0].equals("event")) {
                eventCommand(splitString,tasks);
            } else if (splitString[0].equals("delete")){
                deleteCommand(splitString,tasks);
            } else if (splitString[0].equals("find")) {
                findCommand(splitString,tasks);
            } else {
                    errorCommand();
                }
            }
        }

    private static void listCommand(TaskList tasks) {
        /**
         * This method prints the list of tasks
         *
         * @param tasks list of tasks to be printed
         */

        System.out.println("Here are the tasks on your list:");
        for (int i = 0; i < tasks.getSize(); i++) {
            System.out.printf("%d. %s\n",i +1,tasks.getIndex(i).toString());
        }
    }

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