Giter Site home page Giter Site logo

ip's Issues

Sharing iP code quality feedback [for @reneeyeow02] - Round 2

@reneeyeow02 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/meowmeow/Parser.java lines 19-108:

    public static Command parse(String userInput) {

        userInput = userInput.trim();
        String[] splitUI = userInput.split(" ");
        assert splitUI.length > 0 : "splitUI should not be empty";
        switch (splitUI[0]) {

        case "hi":
            return new HiCommand();

        case "list":
            return new ListCommand();

        case "bye":
            return new ExitCommand();

        case "undo":
            return new UndoCommand();

        default:
            break;
        }

        String[] splitUserInput = userInput.split(" ", 2);

        String cmdWord = splitUserInput[0];

        switch (cmdWord) {
        case "mark":
            try {
                int taskNum = Integer.parseInt(splitUserInput[1]);
                return new MarkCommand(true, taskNum);
            } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
                return new DefaultCommand("=0w0= Meowmeow needs a number for the task you want to mark!");
            }

        case "unmark":
            try {
                int taskNum = Integer.parseInt(splitUserInput[1]);
                return new MarkCommand(false, taskNum);
            } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
                return new DefaultCommand("=0w0= Meowmeow needs a number for the task you want to unmark!");
            }

        case "todo":
            try {
                String taskName = splitUserInput[1];
                return new AddCommand('T', taskName);
            } catch (ArrayIndexOutOfBoundsException e) {
                return new DefaultCommand("=0w0= Meowmeow needs a name for the todo you want to add!");
            }

        case "deadline":
            try {
                String nameAndLocalDateTime = splitUserInput[1];
                return new AddCommand('D', nameAndLocalDateTime);
            } catch (ArrayIndexOutOfBoundsException e) {
                return new DefaultCommand("=0w0= To add a deadline type it in in this format: "
                        + "deadline (name) /by (YYYY-MM-DDTHH:MM:SS)");
            }

        case "event":
            try {
                String nameAndTime = splitUserInput[1];
                return new AddCommand('E', nameAndTime);
            } catch (ArrayIndexOutOfBoundsException e) {
                return new DefaultCommand("=0w0= To add an event type it in in this format: event (name) /at (time)");
            }

        case "delete":
            try {
                int taskToDelete = Integer.parseInt(splitUserInput[1]);
                return new DeleteCommand(taskToDelete);
            } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
                return new DefaultCommand("=0w0= Meowmeow needs a number for the task you want to delete!");
            }

        case "find":
            try {
                String taskToFind = splitUserInput[1];
                return new FindCommand(taskToFind);
            } catch (ArrayIndexOutOfBoundsException e) {
                return new DefaultCommand("=0w0= Meowmeow needs a name for the task you want to find!");
            }

        default:
            return new DefaultCommand("Sowwie meowmeow doesn't understand what you said uwu โ™ฅ \n"
                    + "Try typing something else! owo");
        }
    }

Example from src/main/java/meowmeow/Storage.java lines 60-127:

    public ArrayList<Task> parseSaveFile(File txt) {
        try {
            txt.getAbsolutePath();
            txt.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }

        Scanner sc = null;
        try {
            sc = new Scanner(txt);
            while (sc.hasNextLine()) {
                String text = sc.nextLine();

                String[] split = text.split(" \\| ");
                assert split.length > 0 : "Save file is empty";
                String firstChar = split[0];
                assert firstChar == "T" || firstChar == "D" || firstChar == "E" : "Save file is corrupted";

                switch (firstChar) {
                case "T":
                    String taskName = split[2];

                    Task todo = new ToDo(taskName);
                    taskList.add(todo);

                    boolean isDone = Boolean.parseBoolean(split[1]);
                    if (isDone) {
                        todo.markAsDone();
                    }
                    break;

                case "D":
                    taskName = split[2];

                    LocalDateTime date = LocalDateTime.parse(split[3]);

                    Task deadline = new Deadline(taskName, date);
                    taskList.add(deadline);

                    isDone = Boolean.parseBoolean(split[1]);
                    if (isDone) {
                        deadline.markAsDone();
                    }
                    break;

                case "E":
                    taskName = split[2];

                    String time = split[3];

                    Task event = new Event(taskName, time);
                    taskList.add(event);

                    isDone = Boolean.parseBoolean(split[1]);
                    if (isDone) {
                        event.markAsDone();
                    }
                    break;
                default:
                    break;
                }
            }
        } catch (FileNotFoundException e) {
            System.out.println(e.toString());
        }
        return taskList;
    }

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

Example from src/main/java/meowmeow/Meowmeow.java lines 24-28:

    /**
     * Method that gets the response from the chatbot.
     *
     * @param input the user input.
     */

Example from src/main/java/meowmeow/events/Task.java lines 22-24:

    /**
     * Method that marks the task as done.
     */

Example from src/main/java/meowmeow/events/Task.java lines 29-31:

    /**
     * Method that marks the task as not done.
     */

Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.

Aspect: Recent Git Commit Message (Subject Only)

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.

Sharing iP code quality feedback [for @reneeyeow02]

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

No easy-to-detect issues ๐Ÿ‘

Aspect: Dead Code

No easy-to-detect issues ๐Ÿ‘

Aspect: Method Length

Example from src/main/java/meowmeow/Parser.java lines 17-77:

    public static Command parse(String userInput) {

        try {
            String[] splitUI = userInput.split(" ");
            switch (splitUI[0]) {
            case "list":
                return new ListCommand();

            case "bye":
                return new ExitCommand();

            default:
                break;
            }

            String[] splitUserInput = userInput.split(" ", 2);

            if (splitUserInput.length <= 1) {
                throw new MeowmeowException("Sowwie meowmeow doesn't understand what you said uwu");
            } else {
                String cmdWord = splitUserInput[0];

                switch (cmdWord) {
                case "mark":
                    int taskNum = Integer.parseInt(splitUserInput[1]);
                    return new MarkCommand(true, taskNum);

                case "unmark":
                    taskNum = Integer.parseInt(splitUserInput[1]);
                    return new MarkCommand(false, taskNum);

                case "todo":
                    String taskName = splitUserInput[1];
                    return new AddCommand('T', taskName);

                case "deadline":
                    String nameAndLocalDateTime = splitUserInput[1];
                    return new AddCommand('D', nameAndLocalDateTime);

                case "event":
                    String nameAndTime = splitUserInput[1];
                    return new AddCommand('E', nameAndTime);

                case "delete":
                    int taskToDelete = Integer.parseInt(splitUserInput[1]);
                    return new DeleteCommand(taskToDelete);

                case "find":
                    String taskToFind = splitUserInput[1];
                    return new FindCommand(taskToFind);

                default:
                    return new DefaultCommand();
                }
            }

        } catch (MeowmeowException e) {
            System.out.println(e);
        }
        return new DefaultCommand();
    }

Example from src/main/java/meowmeow/Storage.java lines 60-125:

    public ArrayList<Task> parseSaveFile(File txt) {
        try {
            txt.getAbsolutePath();
            txt.createNewFile();
        } catch (IOException e) {
            e.printStackTrace();
        }

        Scanner sc = null;
        try {
            sc = new Scanner(txt);
            while (sc.hasNextLine()) {
                String text = sc.nextLine();

                String[] split = text.split(" \\| ");
                String firstChar = split[0];

                switch (firstChar) {
                case "T":
                    String taskName = split[2];

                    Task todo = new ToDo(taskName);
                    taskList.add(todo);

                    boolean isDone = Boolean.parseBoolean(split[1]);
                    if (isDone) {
                        todo.markAsDone();
                    }
                    break;

                case "D":
                    taskName = split[2];

                    LocalDateTime date = LocalDateTime.parse(split[3]);

                    Task deadline = new Deadline(taskName, date);
                    taskList.add(deadline);

                    isDone = Boolean.parseBoolean(split[1]);
                    if (isDone) {
                        deadline.markAsDone();
                    }
                    break;

                case "E":
                    taskName = split[2];

                    String time = split[3];

                    Task event = new Event(taskName, time);
                    taskList.add(event);

                    isDone = Boolean.parseBoolean(split[1]);
                    if (isDone) {
                        event.markAsDone();
                    }
                    break;
                default:
                    break;
                }
            }
        } catch (FileNotFoundException e) {
            System.out.println(e.getMessage());
        }
        return taskList;
    }

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

Example from src/main/java/meowmeow/Meowmeow.java lines 46-48:

    /**
     * Method that runs the program.
     */

Example from src/main/java/meowmeow/Meowmeow.java lines 66-70:

    /**
     * Main method that runs the program.
     *
     * @param args the command line arguments.
     */

Example from src/main/java/meowmeow/Meowmeow.java lines 75-78:

    /**
     * You should have your own function to generate a response to user input.
     * Replace this stub with your completed method.
     */

Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement.

Aspect: Recent Git Commit Message (Subject Only)

possible problems in commit 08cacd5:

JavaFX

  • Perhaps too short (?)

possible problems in commit 044d6a1:

A-Jar

  • Perhaps too short (?)

possible problems in commit bc21226:

A-Jar

  • Perhaps too short (?)

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.