Skip to content

Sharing iP code quality feedback [for @kararei] #1

@nus-se-bot

Description

@nus-se-bot

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

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

Example from src/main/java/misc/kxException.java lines 3-3:

public class kxException extends Exception {

Example from src/main/java/kx/kx.java lines 14-14:

public class kx {

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

Aspect: Dead Code

Example from src/main/java/misc/Storage.java lines 26-26:

        //System.out.println("updating file");

Example from src/main/java/misc/Storage.java lines 30-30:

        //System.out.println("directory created");

Example from src/main/java/misc/Storage.java lines 34-34:

                //System.out.println("task added");

Suggestion: Remove dead code from the codebase.

Aspect: Method Length

Example from src/main/java/misc/Parser.java lines 22-154:

    public void userCommand(String message) throws kxException {
        String[] input = message.split(" ", 2);
        String command = input[0];

        if (input.length == 1 && !command.equals("list") && !command.equals("bye")) {
            throw new kxException("  ERROR! The description of a task cannot be empty.");
        }

        switch (command) {
            case "bye":
                ui.byeMessage();

                break;

            case "list":
                ui.listTaskMessage(taskList);

                break;
            case "mark": {
                Task task = taskList.get(Integer.parseInt(input[1]) - 1);
                task.markAsDone();
                ui.markMessage(task);

                //Update changes
                try {
                    Storage.updateFile(taskList);
                } catch (IOException e) {
                    System.out.println("Error in updating misc.Storage: " + e.getMessage());
                }

                break;
            }
            case "unmark": {
                Task task = taskList.get(Integer.parseInt(input[1]) - 1);
                task.markAsUndone();
                ui.unmarkMessage(task);

                // Update changes
                try {
                    Storage.updateFile(taskList);
                } catch (IOException e) {
                    System.out.println("Error in updating misc.Storage: " + e.getMessage());
                }

                break;
            }
            case "deadline": {

                // check for /by
                if (!input[1].contains(" /by ")) {
                    throw new kxException("  ERROR! The description of a deadline must include /by.");
                }
                String[] outputs = input[1].split(" /by ");

                // Check for both task and deadline on input
                if (outputs.length != 2) {
                    throw new kxException("  ERROR! The description must include both the task and the deadline.");
                }

                Deadlines newTask = new Deadlines(outputs[0], outputs[1]);
                taskList.add(newTask);
                ui.addTaskMessage(taskList, newTask);
                // Update changes
                try {
                    Storage.updateFile(taskList);
                } catch (IOException e) {
                    ui.errorMessage(e.getMessage());
                }


                break;
            }
            case "todo": {
                Todo newTask = new Todo(input[1]);
                taskList.add(newTask);
                ui.addTaskMessage(taskList, newTask);

                // Update changes
                try {
                    Storage.updateFile(taskList);
                } catch (IOException e) {
                    ui.errorMessage(e.getMessage());
                }

                break;
            }
            case "event": {

                // check for /from and /to
                if (!input[1].contains(" /from ") || !input[1].contains(" /to ")) {
                    throw new kxException("  ERROR! The description of a deadline must include /from and /to.");
                }

                String[] outputs = input[1].split(" /from ");
                // check for both task and event
                if (outputs.length != 2) {
                    throw new kxException("  ERROR! The description must include the event, start, and end timings. It cannot be empty.");
                }

                String[] outputs2 = outputs[1].split(" /to ");
                // check for both task and event
                if (outputs2.length != 2) {
                    throw new kxException("  ERROR! The description must include the start and end timings. It cannot be empty.");
                }
                Events newTask = new Events(outputs[0], outputs2[0], outputs2[1]);
                taskList.add(newTask);
                ui.addTaskMessage(taskList, newTask);

                // Update changes
                try {
                    Storage.updateFile(taskList);
                } catch (IOException e) {
                    ui.errorMessage(e.getMessage());
                }

                break;
            }
            case "delete":
                Task currTask = taskList.get(Integer.parseInt(input[1]) - 1);
                taskList.remove(Integer.parseInt(input[1]) - 1);
                ui.deleteMessage(taskList, currTask);

                // Update changes
                try {
                    Storage.updateFile(taskList);
                } catch (IOException e) {
                    System.out.println("Error in updating misc.Storage: " + e.getMessage());
                }
                break;
            default:
                throw new kxException("  ERROR! I'm sorry, but I am unable to handle that command yet :(");
        }
    }

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 Messages

possible problems in commit 6e50ef5:


Merge branch 'add-gradle-support'
Add gradle support


  • No blank line between subject and body

possible problems in commit 5bb1be0:


Merge branch 'MoreOOP'
Refactor code for more OOP


  • No blank line between subject and body

possible problems in commit 961606f:


Merge branch 'branch-Level-8'
Merge Level-8 branch into master


  • No blank line between subject and body

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 👍


ℹ️ 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.

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