Skip to content

Sharing iP code quality feedback [for @sianloh] - Round 2 #2

Description

@nus-se-bot

@sianloh We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, so that you can avoid similar problems in your tP code (which will be graded more strictly for code quality).

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.java lines 16-101:

    public static void main(String[] args) {
        String logo = " ____        _        \n"
                + "|  _ \\ _   _| | _____ \n"
                + "| | | | | | | |/ / _ \\\n"
                + "| |_| | |_| |   <  __/\n"
                + "|____/ \\__,_|_|\\_\\___|\n";

        System.out.println("Hello from\n" + logo);
        printbreak();
        System.out.println("Hello! I'm Duke ");
        System.out.println("What can I do for you?");
        printbreak();
        String line;
        Task[] lists = new Task[100];
        int counter = 0;
        String desc;
        String desc2 = "";
        String s1, s2;
        while (true) {

            Scanner in = new Scanner(System.in);
            line = in.nextLine();
            if (!line.isEmpty()) {
                if (line.contains(" ")) {
                    String[] input = line.split(" ", 2);
                    desc = input[0];
                    desc2 = input[1];
                } else {
                    desc = line;
                }
                if (line.equalsIgnoreCase("bye"))
                    break;
                if (line.equalsIgnoreCase("list")) {
                    printbreak();
                    for (int i = 0; i < counter; i++) {
                        System.out.println(i + 1 + ". " + lists[i].toString());
                    }
                    printbreak();
                } else if (desc.equalsIgnoreCase("done")) {
                    printbreak();
                    int x = Integer.parseInt(desc2);
                    lists[x - 1].setDone(true);
                    System.out.println("Nice! I've marked this task as done: ");
                    System.out.println(lists[x - 1].toString());
                    printbreak();
                } else if (desc.equalsIgnoreCase("deadline")) {
                    printbreak();
                    String[] input = desc2.split("/by ", 2);
                    s1 = input[0];
                    s2 = input[1];
                    lists[counter] = new Deadline(s1, s2);
                    System.out.println("Got it. I've added this task: ");
                    System.out.println(lists[counter].toString());
                    counter++;
                    printtotaltask(counter);
                    printbreak();
                } else if (desc.equalsIgnoreCase("event")) {
                    printbreak();
                    String[] input = desc2.split("/at ", 2);
                    s1 = input[0];
                    s2 = input[1];
                    lists[counter] = new Event(s1, s2);
                    System.out.println("Got it. I've added this task: ");
                    System.out.println(lists[counter].toString());
                    counter++;
                    printtotaltask(counter);
                    printbreak();
                } else {
                    printbreak();
                    if (desc.equalsIgnoreCase("todo")){
                        lists[counter] = new ToDo(desc2);
                    }else {
                        lists[counter] = new ToDo(line);
                    }
                    System.out.println("Got it. I've added this task: ");
                    System.out.println(lists[counter].toString());
                    counter++;
                    printtotaltask(counter);
                    printbreak();
                }
            }
        }
        printbreak();
        printbye();
        printbreak();
    }

Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten 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 👍

ℹ️ The bot account @nus-se-bot used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact tic2002@comp.nus.edu.sg if you want to follow up on this post.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions