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

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

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

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

Comments

@soc-se-bot-blue
Copy link

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

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/meowmeow/Parser.java lines 17-77:

    public static Command parse(String userInput) {

        try {
            String[] splitUI = userInput.split(" ");
            switch (splitUI[0]) {
            case "list":
                return new ListCommand();

            case "bye":
                return new ExitCommand();

            default:
                break;
            }

            String[] splitUserInput = userInput.split(" ", 2);

            if (splitUserInput.length <= 1) {
                throw new MeowmeowException("Sowwie meowmeow doesn't understand what you said uwu");
            } else {
                String cmdWord = splitUserInput[0];

                switch (cmdWord) {
                case "mark":
                    int taskNum = Integer.parseInt(splitUserInput[1]);
                    return new MarkCommand(true, taskNum);

                case "unmark":
                    taskNum = Integer.parseInt(splitUserInput[1]);
                    return new MarkCommand(false, taskNum);

                case "todo":
                    String taskName = splitUserInput[1];
                    return new AddCommand('T', taskName);

                case "deadline":
                    String nameAndLocalDateTime = splitUserInput[1];
                    return new AddCommand('D', nameAndLocalDateTime);

                case "event":
                    String nameAndTime = splitUserInput[1];
                    return new AddCommand('E', nameAndTime);

                case "delete":
                    int taskToDelete = Integer.parseInt(splitUserInput[1]);
                    return new DeleteCommand(taskToDelete);

                case "find":
                    String taskToFind = splitUserInput[1];
                    return new FindCommand(taskToFind);

                default:
                    return new DefaultCommand();
                }
            }

        } catch (MeowmeowException e) {
            System.out.println(e);
        }
        return new DefaultCommand();
    }

Example from src/main/java/meowmeow/Storage.java lines 60-125:

    public ArrayList<Task> parseSaveFile(File txt) {
        try {
            txt.getAbsolutePath();
            txt.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }

        Scanner sc = null;
        try {
            sc = new Scanner(txt);
            while (sc.hasNextLine()) {
                String text = sc.nextLine();

                String[] split = text.split(" \\| ");
                String firstChar = split[0];

                switch (firstChar) {
                case "T":
                    String taskName = split[2];

                    Task todo = new ToDo(taskName);
                    taskList.add(todo);

                    boolean isDone = Boolean.parseBoolean(split[1]);
                    if (isDone) {
                        todo.markAsDone();
                    }
                    break;

                case "D":
                    taskName = split[2];

                    LocalDateTime date = LocalDateTime.parse(split[3]);

                    Task deadline = new Deadline(taskName, date);
                    taskList.add(deadline);

                    isDone = Boolean.parseBoolean(split[1]);
                    if (isDone) {
                        deadline.markAsDone();
                    }
                    break;

                case "E":
                    taskName = split[2];

                    String time = split[3];

                    Task event = new Event(taskName, time);
                    taskList.add(event);

                    isDone = Boolean.parseBoolean(split[1]);
                    if (isDone) {
                        event.markAsDone();
                    }
                    break;
                default:
                    break;
                }
            }
        } catch (FileNotFoundException e) {
            System.out.println(e.getMessage());
        }
        return taskList;
    }

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

Example from src/main/java/meowmeow/Meowmeow.java lines 46-48:

    /**
     * Method that runs the program.
     */

Example from src/main/java/meowmeow/Meowmeow.java lines 66-70:

    /**
     * Main method that runs the program.
     *
     * @param args the command line arguments.
     */

Example from src/main/java/meowmeow/Meowmeow.java lines 75-78:

    /**
     * You should have your own function to generate a response to user input.
     * Replace this stub with your completed method.
     */

Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.

Aspect: Recent Git Commit Message (Subject Only)

possible problems in commit 08cacd5:

JavaFX

  • Perhaps too short (?)

possible problems in commit 044d6a1:

A-Jar

  • Perhaps too short (?)

possible problems in commit bc21226:

A-Jar

  • Perhaps too short (?)

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 cs2103@comp.nus.edu.sg 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