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

Open
soc-se-script opened this issue Sep 10, 2022 · 0 comments
Open

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

soc-se-script opened this issue Sep 10, 2022 · 0 comments

Comments

@soc-se-script
Copy link

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

Example from src/main/java/Duke.java lines 178-179:

            else {

Suggestion: As specified by the coding standard, use egyptian style braces.

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 24-199:

    public static void main(String[] args) throws DukeException, IOException, IllegalCommandException {
        String logo = " ____        _        \n"
                + "|  _ \\ _   _| | _____ \n"
                + "| | | | | | | |/ / _ \\\n"
                + "| |_| | |_| |   <  __/\n"
                + "|____/ \\__,_|_|\\_\\___|\n";
        System.out.println("Hello from\n" + logo);
        System.out.println("___________________________________");
        System.out.println("Hello! I'm Duke\n What can I do for you?");
        System.out.println("____________________________________");

        String input = sc.nextLine();

        File file = new File("database/duke.txt");
        if (file.createNewFile()) {
            System.out.println("File has been created: " + file.getName());
        } else {
            System.out.println("File already exists.");
            Scanner reader = new Scanner(file);
            while (reader.hasNext()) {
                reader.useDelimiter(" \\| ");
                Constants constant = Constants.valueOf(reader.next().toUpperCase());
                Task task;
                switch (constant) {
                    case TODO:
                        String tdDescription = reader.next();
                        Todo todo = new Todo(tdDescription);
                        collection.add(todo);
                        break;
                    case DEADLINE:
                        String dlDescription = reader.next();
                        Deadline deadline = new Deadline(dlDescription);
                        collection.add(deadline);
                        break;
                    case EVENT:
                        String evDescription = reader.next();
                        Event event = new Event(evDescription);
                        collection.add(event);
                        break;

                    default:
                        throw new IllegalCommandException("Illegal command given");
                }
            }
        }




        while (!input.equals("bye")) {

            if (input.equals("list")) {
                System.out.println("___________________________________");
                for (int i = 0; i < collection.size(); i++) {
                    System.out.println( (i+1) + "."
                            + collection.get(i).toString());
                }
                System.out.println("___________________________________");
                input = sc.nextLine();

            }

            if (input.startsWith("mark")) {
                int number = Integer.parseInt(input.substring(5));
                collection.get(number-1).mark();
                System.out.println("___________________________________");
                System.out.println("Nice! I've marked this task done: " + "\n"
                        + "[" + collection.get(number-1).getStatusIcon() + "] " +
                        collection.get(number-1).description);
                System.out.println("___________________________________");
                input = sc.nextLine();
            }

            if (input.equals("unmark")) {
                int number = Integer.parseInt(input.substring(7));
                collection.get(number-1).unmark();
                System.out.println("___________________________________");
                System.out.println("OK, I've marked this task as not done yet: " + "\n"
                        + "[" + collection.get(number-1).getStatusIcon() + "] " +
                        collection.get(number-1).description);
                System.out.println("___________________________________");
                input = sc.nextLine();
            }

            if (input.startsWith("deadline")) {
                try {
                    if (isNotValid(input))
                        throw new DukeException("☹ OOPS!!! The description of a deadline cannot be empty.");
                    Deadline deadline = new Deadline(input);
                    collection.add(deadline);
                    System.out.println("___________________________________");
                    System.out.println("Got it. I've added this task:" + "\n"
                            + "  " + deadline.toString() + "\n"
                            + "Now you have " + collection.size() + " tasks in the list.");
                    System.out.println("___________________________________");
                } catch(DukeException e) {
                    System.out.println(e.getMessage());

                } finally {
                    input = sc.nextLine();
                }
            }

            if (input.startsWith("todo")) {
                try {
                    if (isNotValid(input))
                        throw new DukeException("☹ OOPS!!! The description of a todo cannot be empty.");
                    Todo todo = new Todo(input);
                    collection.add(todo);
                    System.out.println("___________________________________");
                    System.out.println("Got it. I've added this task:" + "\n"
                            + "  " + todo.toString() + "\n"
                            + "Now you have " + collection.size() + " tasks in the list.");
                    System.out.println("___________________________________");
                } catch(DukeException e) {
                    System.out.println(e.getMessage());

                } finally {
                    input = sc.nextLine();
                }
            }

            if (input.startsWith("event")) {
                try {
                    if (isNotValid((input)))
                        throw new DukeException("☹ OOPS!!! The description of a event cannot be empty.");
                    Event event = new Event(input);
                    collection.add(event);
                    System.out.println("___________________________________");
                    System.out.println("Got it. I've added this task:" + "\n"
                            + "  " + event.toString() + "\n"
                            + "Now you have " + collection.size() + " tasks in the list.");
                    System.out.println("___________________________________");
                } catch(DukeException e) {
                    System.out.println(e.getMessage());

                } finally {
                    input = sc.nextLine();
                }
            }


            if (input.startsWith("delete")) {
                int number = Integer.parseInt(input.substring(7));
                Task temp = collection.get(number-1);
                collection.remove(number-1);
                System.out.println("___________________________________");
                System.out.println("Noted. I've removed this task:" + "\n"
                        + "  " + temp.toString() + "\n"
                        + "Now you have " + collection.size() + " tasks in the list.");
                System.out.println("___________________________________");
                input = sc.nextLine();

            }

            else {
                try {
                    throw new DukeException(" ☹ OOPS!!! I'm sorry, but I don't know what that means :-(.");
                } catch (DukeException e) {
                    System.out.println(e.getMessage());
                } finally {
                    input = sc.nextLine();
                }
            }
        }

        FileWriter fileWriter = new FileWriter(file);
        for (Task task : collection) {
            fileWriter.write(task.fileFormat() + System.lineSeparator());
        }
        fileWriter.close();

        System.out.println("___________________________________");
        System.out.println("Bye. Hope to see you again soon!");
        System.out.println("___________________________________");
    }

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 495d75f:

edited Level 2

  • 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