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 @RiyaMehta2211] - Round 2 #4

Open
soc-se-bot-blue opened this issue Oct 16, 2023 · 0 comments
Open

Comments

@soc-se-bot-blue
Copy link

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

Example from src/main/java/duke/Parser.java lines 134-135:

            }
            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

Example from src/test/java/duke/StorageTest.java lines 27-27:

            //assert storage.loadTasks("src/data/newFile.txt").equals(tasks);

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/duke/Parser.java lines 29-78:

    private static void updateTask(String str, TaskList tasks) throws InvalidInputException, EmptyInputException, TaskTypeMismatchException {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HHmm");
        String num = str.substring(7, 8);
        int number = Integer.valueOf(num);
        if (number <= 0 || number > tasks.getSize()) {
            throw new InvalidInputException(str);
        }
        int index = number - 1;
        Task task = tasks.getTask(index);
        if (str.contains("/description")) {
            String description = str.substring(21).trim();
            if (description.isEmpty()) {
                throw new EmptyInputException();
            }
            task.updateDescription(description);
        } else if (str.contains("/deadline")) {
            if (!task.taskString().contains("[D]")) {
                throw new TaskTypeMismatchException(str);
            }
            String date = str.substring(18).trim();
            if (date.isEmpty()) {
                throw new EmptyInputException();
            }
            Deadline deadline = (Deadline) task;
            deadline.updateDateTime(LocalDateTime.parse(date, formatter));
        } else if (str.contains("/event start date")) {
            if (!task.taskString().contains("[E]")) {
                throw new TaskTypeMismatchException(str);
            }
            String date = str.substring(27).trim();
            if (date.isEmpty()) {
                throw new EmptyInputException();
            }
            Event event = (Event) task;
            event.updateStartDateTime(LocalDateTime.parse(date, formatter));
        } else if (str.contains("/event end date")) {
            if (!task.taskString().contains("[E]")) {
                throw new TaskTypeMismatchException(str);
            }
            String date = str.substring(25).trim();
            if (date.isEmpty()) {
                throw new EmptyInputException();
            }
            Event event = (Event) task;
            event.updateEndDateTime(LocalDateTime.parse(date, formatter));
        } else {
            throw new InvalidInputException(str);
        }
        temp =  Ui.printUpdatedTask(task);
    }

Example from src/main/java/duke/Parser.java lines 85-149:

    private static void updateList(String str, TaskList tasks) throws InvalidInputException, EmptyInputException, TaskTypeMismatchException {
        if (str.startsWith("mark ")) {
            if (str.startsWith("mark all")) {
                for (int i = 0; i < tasks.getSize(); i++) {
                    tasks.markDone(i);
                }
                temp = Ui.printAllDone(tasks);
            } else {
                String num = str.substring(5);
                if (num.trim().isEmpty()) {
                    throw new EmptyInputException();
                }
                int number = Integer.valueOf(num);
                if (number <= 0 || number > tasks.getSize()) {
                    throw new InvalidInputException(str);
                }
                int index = number - 1; //index for task list
                tasks.markDone(index);
                Task done = tasks.getTask(index);
                temp = Ui.printDone(done);
            }
        } else if (str.startsWith("unmark ")) {
            if (str.startsWith("unmark all")) {
                for (int i = 0; i < tasks.getSize(); i++) {
                    tasks.markNotDone(i);
                }
                temp = Ui.printAllNotDone(tasks);
            } else {
                String num = str.substring(7);
                if (num.trim().isEmpty()) {
                    throw new EmptyInputException();
                }
                int number = Integer.valueOf(num);
                if (number <= 0 || number > tasks.getSize()) {
                    throw new InvalidInputException(str);
                }
                int index = number - 1; //index for task list
                tasks.markNotDone(index);
                Task notDone = tasks.getTask(index);
                temp = Ui.printNotDone(notDone);
            }
        } else if (str.startsWith("update ")) {
            updateTask(str, tasks);
        } else if (str.startsWith("delete ")) {
            if (str.startsWith("delete all")) {
                while (tasks.getSize() != 0) {
                    tasks.removeTask(0);
                }
                temp = Ui.printAllDeleted(tasks);
            }
            else {
                String num = str.substring(7);
                if (num.trim().isEmpty()) {
                    throw new EmptyInputException();
                }
                int number = Integer.valueOf(num);
                if (number <= 0 || number > tasks.getSize()) {
                    throw new InvalidInputException(str);
                }
                int index = number - 1;
                Task toBeDeleted = tasks.removeTask(index);
                temp = Ui.printDelete(toBeDeleted, tasks);
            }
        }
    }

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

possible problems in commit 516539c:


Fix minor issues to align with coding standards and improve coding quality


  • Longer than 72 characters

possible problems in commit 94c43a3:


Removing commented out bits to improve code quality


  • Not in imperative mood (?)

possible problems in commit d27b0b3:


add C-update extension to update attributes of the specified task in the list. Add extra exceptions for more efficient error handling


  • Longer than 72 characters

Suggestion: Follow the given conventions for Git commit messages for future commits (do not modify past commit messages as doing so will change the commit timestamp that we used to detect your commit timings).

Aspect: Binary files in repo

No easy-to-detect issues 👍


❗ You are not required to (but you are welcome to) fix the above problems in your iP, unless you have been separately asked to resubmit the iP due to code quality 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