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 check results [for @katelo731] #1

Open
nus-pe-script opened this issue Feb 23, 2020 · 0 comments
Open

Sharing iP code quality check results [for @katelo731] #1

nus-pe-script opened this issue Feb 23, 2020 · 0 comments

Comments

@nus-pe-script
Copy link

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

Example from src/main/java/Duke.java line 74:

        while (itr.hasNext())
        {

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

No easy-to-detect issues 👍

Aspect: Method Length

Example from src/main/java/Duke.java line 212:

    private static void addLoadedTask (@NotNull String cmd, ArrayList<Task> tasks) {
        String[] words = cmd.split(" ");
        String taskType = words[0];
        String taskStatus = words[1];
        int indexOfCommand = 8;
        int indexOfTimePosition = 6;
        String cmdTask = cmd.substring(indexOfCommand);

        boolean isToDo = taskType.equals("[T]");
        boolean isDeadline = taskType.equals("[D]");
        boolean isEvent = taskType.equals("[E]");
        boolean isDone = taskStatus.equals("[v]");

        FindDukeException findDukeException = new FindDukeException(cmd);
        try {
            if (isToDo) {
                Task todo = new Todo(tasks.size(), cmdTask, isDone);
                tasks.add(todo);
            } else if (isEvent) {
                int timePosition = cmdTask.indexOf(" /at: ");
                String cmdEvent = cmdTask.substring(0, timePosition);
                String cmdTime = cmdTask.substring(timePosition + indexOfTimePosition);
                Task event = new Event(tasks.size(), cmdEvent, isDone, cmdTime);
                tasks.add(event);
            } else if (isDeadline) {
                int timePosition = cmdTask.indexOf(" /by: ");
                String cmdDeadline = cmdTask.substring(0, timePosition);
                String cmdTime = cmdTask.substring(timePosition + indexOfTimePosition);
                Task deadline = new Deadline(tasks.size(), cmdDeadline, isDone, cmdTime);
                tasks.add(deadline);
            } else {
                findDukeException.undefinedTypeException();
            }
        } catch (DukeException dukeException) {
            System.out.println("        ╔═══════════════════════════════════════════════════════════╗");
            printInCenter(dukeException.getMessage());
            System.out.println("        ╚═══════════════════════════════════════════════════════════╝");
        }
    }

Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods.

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