Skip to content

Sharing iP code quality feedback [for @tashawan23] #3

@nus-se-bot

Description

@nus-se-bot

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 code further.

IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most one example is given i.e., there can be other areas/places to improve.

Aspect: Tab Usage

No easy-to-detect issues 👍

Aspect: Brace Style

No easy-to-detect issues 👍

Aspect: Package Name Style

Example from src/main/java/duke/Exceptions/DukeExceptions.java lines 1-1:

package duke.Exceptions;

Suggestion: Follow the package naming convention specified by the coding standard.

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/Duke.java lines 29-86:

    public String getResponse(String input) {
        Parser commandParser = new Parser();
        String speech = "";
        try {
            commandParser.parse(input);
            String action = commandParser.getCommand(input);
            assert action.length() > 1 : "Action not retrieved accurately";
            String desc = commandParser.getDesc(input);
            switch (action) {
            case "bye":
                speech += ui.sayGoodbye();
                break;
            case "list":
                speech += ui.printList(tasks.getTaskList());
                break;
            case "done":
                int n = Integer.parseInt(desc);
                Task t = tasks.completeTask(n, tasks);
                speech += ui.printChecked(t);
                break;
            case "todo":
                Task todo = tasks.addTodo(desc, tasks);
                speech += ui.printAdded(tasks.getTaskList(), todo);
                break;
            case "event":
                String date = commandParser.getDate(input);
                Task event = tasks.addEvent(desc, date, tasks);
                speech += ui.printAdded(tasks.getTaskList(), event);
                break;
            case "deadline":
                String due = commandParser.getDate(input);
                Task deadline = tasks.addDeadline(desc, due, tasks);
                speech += ui.printAdded(tasks.getTaskList(), deadline);
                break;
            case "delete":
                int index = Integer.parseInt(desc);
                Task task = tasks.getTask(index);
                tasks.deleteTask(index);
                speech += ui.printDeleted(tasks.getTaskList(), task);
                break;
            case "find":
                speech += tasks.findTasks(desc);
                break;
            case "today":
                speech += tasks.getReminder(tasks);
                break;
            case "weekly":
                speech += tasks.getNextReminder(tasks);
                break;
            default:
                throw new UnclearInputException();
            }
        } catch (DukeExceptions e) {
            return e.getMessage();
        }
        storage.write();
        return speech;
    }

Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods. You may ignore this suggestion if you think a longer method is justified in a particular case.

ℹ️ The bot account @cs2103-bot 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions