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

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

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

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

Comments

@soc-se-bot
Copy link

@inezkok 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/util/Storage.java lines 74-145:

    public ArrayList<Task> load() throws DukeException {
        ArrayList<Task> tasks = new ArrayList<>();

        try {
            File f = new File(filePath);
            if (!f.exists()) {
                return tasks;
            }

            Scanner s = new Scanner(f);
            int i = 0;
            while (s.hasNext()) {
                String line = s.nextLine();
                String taskType = line.substring(0, 3);
                String done = line.substring(4, 7);

                if (taskType.equals("[T]")) {
                    String description = line.substring(8);

                    ToDo toDo = new ToDo(description);
                    tasks.add(toDo);
                } else if (taskType.equals("[D]")) {
                    String[] fullLine = line.substring(8).split(":", 2);
                    String description = fullLine[0];
                    String date = fullLine[1];

                    String taskDate = formatDate(date.substring(0, date.length()).trim());
                    validateDate(taskDate);

                    String taskDescription = description.substring(0, description.length() - 3).trim();
                    LocalDate d = LocalDate.parse(taskDate);

                    Deadline deadline = new Deadline(taskDescription, d);
                    tasks.add(deadline);
                } else if (taskType.equals("[E]")) {
                    String[] fullLine = line.substring(8).split(":", 3);
                    String description = fullLine[0];
                    String start = fullLine[1];
                    String end = fullLine[2];

                    String taskStart = formatDate(start.substring(0, start.length() - 2).trim());
                    String taskEnd = formatDate(end.substring(0, end.length() - 1).trim());
                    validateDate(taskStart);
                    validateDate(taskEnd);

                    String taskDescription = description.substring(0, description.length() - 5).trim();
                    LocalDate d1 = LocalDate.parse(taskStart);
                    LocalDate d2 = LocalDate.parse(taskEnd);

                    Event event = new Event(taskDescription, d1, d2);
                    tasks.add(event);
                } else {
                    throw new DukeException("Boop Beep OOPS! File has unexpected task type :(");
                }

                if (done.equals("[X]")) {
                    tasks.get(i).markDone();
                } else if (done.equals("[ ]")) {

                } else {
                    throw new DukeException("Boop Beep OOPS! File has unexpected done value :(");
                }

                i++;
            }

        } catch (FileNotFoundException e) {
            throw new DukeException("Boop Beep OOPS! " + e.getMessage());
        }

        return 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

No easy-to-detect issues 👍

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 [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