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

Open
soc-se-bot opened this issue Sep 14, 2024 · 0 comments
Open

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

soc-se-bot opened this issue Sep 14, 2024 · 0 comments

Comments

@soc-se-bot
Copy link

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

Example from src/main/java/noosy/commands/OnCommand.java lines 45-45:

        boolean found = false;

Example from src/main/java/noosy/task/Task.java lines 10-10:

    protected boolean status;

Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)

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

Example from src/main/java/noosy/gui/MainWindow.java lines 54-54:

//                DialogBox.getNoosyDialog(welcome, noosyImage, );

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/noosy/parser/Parser.java lines 27-139:

    public static Command parse(String fullCommand) throws NoosyException {
        String[] separated = fullCommand.split(" ", 2);
        String firstWord = separated[0];
        String input = separated.length > 1 ? separated[1] : null;

        switch (firstWord) {
            case "bye":
                return new ExitCommand();

            case "list":
                return new ListCommand();

            case "mark":
                if (input == null) {
                    throw new NoosyException("Which task do you want to mark?");
                }

                return new MarkCommand(Integer.parseInt(input.trim()) - 1);

            case "unmark":
                if (input == null) {
                    throw new NoosyException("Which task do you want to unmark?");
                }

                return new UnmarkCommand(Integer.parseInt(input.trim()) - 1);

            case "delete":
                if (input == null) {
                    throw new NoosyException("Which task do you want to delete?");
                }

                return new DeleteCommand(Integer.parseInt(input.trim()) - 1);

            case "find":
                if (input == null) {
                    throw new NoosyException("I can't see the keyword. Try typing it.");
                }

                return new FindCommand(input);

            case "on":
                if (input == null) {
                    throw new NoosyException("You forgot the date! \n" +
                            "It should be formatted as: yyyy-MM-dd");
                }

                try {
                    LocalDate date = LocalDate.parse(input, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
                    return new OnCommand(date);
                } catch (DateTimeParseException e) {
                    throw new NoosyException("Uh oh! Date should be in the format: yyyy-MM-dd");
                }

            case "todo":
                if (input == null) {
                    throw new NoosyException("Okay surezies but what do you want to do?");
                }

                return new AddCommand(new Todo(input));

            case "deadline":
                if (input == null) {
                    throw new NoosyException("Okay surezies but what do you want to do?");
                }

                String[] withDue = input.split(" /by ");
                if (withDue.length < 2) {
                    throw new NoosyException("I think you forgot the deadline. \n" +
                            "Remember to type in the task and /by the deadline!");
                }

                try {
                    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
                    LocalDate deadline = LocalDate.parse(withDue[1], formatter);
                    return new AddCommand(new Deadline(withDue[0], deadline));
                } catch (DateTimeException e) {
                    throw new NoosyException("The date should be formatted as: yyyy-MM-dd");
                }

            case "event":
                if (input == null) {
                    throw new NoosyException("Okay surezies but what do you want to do?");
                }

                String[] withDuration = input.split(" /from | /to ");
                if (withDuration.length < 3) {
                    throw new NoosyException("I think you forgot the duration. \n" +
                            "Remember to type in the task and /from the start /to the end!");
                }

                try {
                    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm");
                    LocalDateTime from = LocalDateTime.parse(withDuration[1], formatter);
                    LocalDateTime to = LocalDateTime.parse(withDuration[2], formatter);
                    return new AddCommand(new Event(withDuration[0], from, to));
                } catch (DateTimeException e) {
                    throw new NoosyException("Date time format should be: yyyy-MM-dd HHmm");
                }

            default:
                throw new NoosyException("Beep Boop. Noosy is confused... \n" +
                        "Noosy only understands: \n" +
                        "list – listing your tasks \n" +
                        "mark i– mark task i as complete \n" +
                        "unmark i – unmark task i \n" +
                        "delete i – delete task i \n" +
                        "todo – add a task with no time associated \n" +
                        "deadline – add a task with a deadline \n" +
                        "event – add a task with duration \n" +
                        "on – check tasks on a certain date \n" +
                        "bye – say goodbye to Noosy \n");
        }
    }

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/noosy/Noosy.java lines 57-62:

    /**
     * The main entry point for the Noosy application.
     * Creates a new Noosy instance and starts its execution.
     *
     * @param args Command line arguments (not used).
     */

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

No easy-to-detect issues 👍

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