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 @markgcera] #6

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

Sharing iP code quality feedback [for @markgcera] #6

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

Comments

@soc-se-bot-blue
Copy link

@markgcera 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/tasks/Task.java lines 8-8:

    protected boolean done;

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

No easy-to-detect issues 👍

Aspect: Method Length

Example from src/main/java/duke/Parser.java lines 26-66:

    public String parse(String input, ArrayList<Task> taskList) {
        String[] inputParts = input.split(" ", 2);
        String command = inputParts[0];
        TaskWorker worker;
        String output;

        switch (command) {
        case "list":
            worker = new ListWorker();
            output = worker.work(taskList);
            assert !output.isEmpty();
            return output;
        case "mark":
            worker = new MarkWorker();
            output = worker.work(inputParts, taskList, true);
            assert !output.isEmpty();
            return output;
        case "unmark":
            worker = new MarkWorker();
            output = worker.work(inputParts, taskList, false);
            assert !output.isEmpty();
            return output;
        case "delete":
            worker = new DeleteWorker();
            output = worker.work(inputParts, taskList);
            assert !output.isEmpty();
            return output;
        case "find":
            worker = new FindWorker();
            output = worker.work(inputParts, taskList);
            assert !output.isEmpty();
            return output;
        case "bye":
            System.exit(0);
        default:
            worker = new AddWorker();
            output = worker.work(inputParts, taskList);
            assert !output.isEmpty();
            return output;
        }
    }

Example from src/main/java/workers/AddWorker.java lines 24-75:

    public String work(String[] inputParts, ArrayList<Task> taskList) {
        assert inputParts != null;
        try {
            Task newTask;
            if (inputParts.length < 2) {
                throw new IrisException("☹ OOPS!!! The content of a command cannot be empty.");
            }

            String content = inputParts[1];
            switch (inputParts[0]) {
            case "todo":
                TodoDuplicateDetector todoDuplicateDetector = new TodoDuplicateDetector();
                if (todoDuplicateDetector.checkDuplicates(content, taskList)) {
                    return "Error: This todo task already exists.";
                }
                newTask = new Todo(content);
                break;
            case "deadline": {
                String[] contentParts = content.split(" /by ", 2);
                String description = contentParts[0];
                String dateOfDeadline = contentParts[1];
                DeadlineDuplicateDetector deadlineDuplicateDetector = new DeadlineDuplicateDetector();
                if (deadlineDuplicateDetector.checkDuplicates(description, dateOfDeadline, taskList)) {
                    return "Error. This deadline task already exists.";
                }
                newTask = new Deadline(description, dateOfDeadline);
                break;
            }
            case "event": {
                String[] contentParts = content.split(" /from ", 2);
                String[] dateParts = contentParts[1].split(" /to ");
                String description = contentParts[0];
                String dateOfFrom = dateParts[0];
                String dateOfTo = dateParts[1];
                EventDuplicateDetector eventDuplicateDetector = new EventDuplicateDetector();
                if (eventDuplicateDetector.checkDuplicates(description, dateOfFrom, dateOfTo, taskList)) {
                    return "Error. This event task already exists.";
                }
                newTask = new Event(description, dateOfFrom, dateOfTo);
                break;
            }
            default:
                throw new IrisException("☹ OOPS!!! I'm sorry, but I don't know what that means :-(");
            }
            taskList.add(newTask);
            return "Got it. I've added this task:\n" + newTask
                    + "\nNow you have " + taskList.size()
                    + " tasks in the list.";
        } catch (IrisException e) {
            return e.getMessage();
        }
    }

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 cda1cc0:


Add an opening message.


  • Subject line should not end with a period

possible problems in commit 0e45441:


Add DuplicateDetector classes to detect if the Task to be added already exists.


  • Longer than 72 characters
  • Subject line should not end with a period

possible problems in commit bf03461:


Test to see if the OAuth error is caused by content of the yml file or the yml file itself.


  • Longer than 72 characters
  • Subject line should not end with a period

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