Giter Site home page Giter Site logo

ip's People

ip's Issues

Sharing iP code quality feedback [for @crypto-code]

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 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/whobot/main/gui/DisplayBuffer.java lines 76-135:

    public static void printBuffer() {
        long delay = charCount > Gui.getShortTextLimit()
                ? Gui.getLongTextDelay()
                : Gui.getShortTextDelay();
        Thread printThread = new Thread(() -> {
            if (userInput != null && sendButton != null) {
                userInput.setDisable(true);
                sendButton.setDisable(true);
                int i = 0;
                if (!buffer.isEmpty()) {
                    int finalI = i;
                    Platform.runLater(() -> {
                        final Node node = BotDialogBox.getDialog(buffer.get(finalI), false, delay);
                        FadeTransition transition = new FadeTransition(Duration.millis(300), node);
                        transition.setFromValue(0);
                        transition.setToValue(1);
                        parent.getChildren().add(node);
                        transition.play();
                    });
                    try {
                        Thread.sleep(delay * buffer.get(i).length());
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    i++;
                }

                if (buffer.size() > 1) {
                    for (; i < buffer.size(); i++) {
                        int finalI1 = i;
                        Platform.runLater((() -> {
                            final Node node = BotDialogBox.getDialog(buffer.get(finalI1), true, delay);
                            FadeTransition transition = new FadeTransition(Duration.millis(300), node);
                            transition.setFromValue(0);
                            transition.setToValue(1);
                            parent.getChildren().add(node);
                            transition.play();
                            if (finalI1 == buffer.size() - 1) {
                                buffer.removeIf(c -> true);
                            }
                        }));
                        try {
                            Thread.sleep(delay * buffer.get(i).length());
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        if (buffer.size() == 0) {
                            userInput.setDisable(false);
                            sendButton.setDisable(false);
                        }
                    }
                } else {
                    buffer.removeIf(c -> true);
                    userInput.setDisable(false);
                    sendButton.setDisable(false);
                }
            }
        });
        printThread.start();
    }

Example from src/main/java/whobot/utils/Parser.java lines 27-106:

    public int parse(String command, UI ui, Storage storage, TaskList taskList) throws WhoBotException {

        assert ui != null;
        assert storage != null;
        assert taskList != null;

        Helper helper = new Helper(ui);

        if (command.isBlank()) {
            throw new WhoBotException("The input is blank. Please enter something.");
        }

        String[] commandList = command.toLowerCase(Locale.ROOT).split(" ");
        //All commands are taken as case-insensitive
        if (command.toLowerCase(Locale.ROOT).equals("bye") || command.toLowerCase(Locale.ROOT).equals("goodbye")) {
            // If input is bye or goodbye, quits program
            if (!WhoBot.isGui()) {
                ui.goodbye();
            }
            storage.saveMemory(taskList.getList());
            return -1;
        } else if (command.toLowerCase(Locale.ROOT).equals("list")) {
            // If input is list, prints list
            taskList.printList(ui);
        } else if (commandList[0].equals("help")) {
            // If input is list, prints list
            if (commandList.length == 1) {
                helper.showMainHelp();
            } else {
                helper.showCommandHelp(commandList[1]);
            }
        } else if (commandList.length == 2 && commandList[0].equals("done")) {
            //If input starts with done, mark the specific item in list as done
            taskList.markAsDone(commandList[1], ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList.length == 2 && commandList[0].equals("undo")) {
            //If input starts with undo, mark the specific item in list as not done
            taskList.markAsUndone(commandList[1], ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList.length == 2 && commandList[0].equals("delete")) {
            //If input starts with delete, delete the specific item in list
            taskList.deleteFromList(commandList[1], ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList[0].equals("todo")) {
            //If input starts with todos, add that to list
            taskList.addTodo(command, ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList[0].equals("event")) {
            //If input starts with event, add that to list
            taskList.addEvent(command, ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList[0].equals("deadline")) {
            //If input starts with deadline, add that to list
            taskList.addDeadline(command, ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList[0].equals("show")) {
            //If input starts with show, show tasks on specified date
            taskList.showOnDate(command, ui);
        } else if (commandList[0].equals("find")) {
            //If input starts with todos, add that to list
            taskList.findTask(command, ui);
        } else if (commandList[0].equals("tag")) {
            //If input starts with todos, add that to list
            taskList.tagTask(command, ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList[0].equals("untag")) {
            //If input starts with todos, add that to list
            taskList.untagTask(command, ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList[0].equals("list")) {
            //If input starts with todos, add that to list
            taskList.listTagTask(command, ui);
            storage.saveMemory(taskList.getList());
        } else {
            // Else Invalid
            throw new WhoBotException("Oops, That's an invalid command."
                    + " Type in help to get list of possible commands.");
        }
        return 0;
    }

Example from src/main/java/whobot/utils/Storage.java lines 60-116:

    public void readData(ArrayList<Task> list, HashMap<String, ArrayList<Task>> taggedList) throws WhoBotException {
        try {
            Scanner taskReader = new Scanner(taskFile);
            while (taskReader.hasNextLine()) {
                String[] data = taskReader.nextLine().split(" \\| ");
                if (data[0].equals("T")) {
                    Todo tempTodo = new Todo(data[2]);
                    if (data[1].equals("X")) {
                        tempTodo.markAsDone();
                    }
                    if (data.length == 4) {
                        if (!taggedList.containsKey(data[3])) {
                            taggedList.put(data[3], new ArrayList<>());
                        }
                        taggedList.get(data[3]).add(tempTodo);
                        tempTodo.setTag(data[3]);
                    } else {
                        taggedList.get(NO_TAG).add(tempTodo);
                    }
                    list.add(tempTodo);
                } else if (data[0].equals("D")) {
                    Deadline tempDeadline = new Deadline(data[2]);
                    if (data[1].equals("X")) {
                        tempDeadline.markAsDone();
                    }
                    if (data.length == 4) {
                        if (!taggedList.containsKey(data[3])) {
                            taggedList.put(data[3], new ArrayList<>());
                        }
                        taggedList.get(data[3]).add(tempDeadline);
                        tempDeadline.setTag(data[3]);
                    } else {
                        taggedList.get(NO_TAG).add(tempDeadline);
                    }
                    list.add(tempDeadline);
                } else if (data[0].equals("E")) {
                    Event tempEvent = new Event(data[2]);
                    if (data[1].equals("X")) {
                        tempEvent.markAsDone();
                    }
                    if (data.length == 4) {
                        if (!taggedList.containsKey(data[3])) {
                            taggedList.put(data[3], new ArrayList<>());
                        }
                        taggedList.get(data[3]).add(tempEvent);
                        tempEvent.setTag(data[3]);
                    } else {
                        taggedList.get(NO_TAG).add(tempEvent);
                    }
                    list.add(tempEvent);
                }
            }
        } catch (FileNotFoundException e) {
            throw new WhoBotException("Oops, The file to store my data could not be created."
                    + " If you continue, tasks won't be stored permanently.");
        }
    }

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.

Aspect: Header Comments

Example from src/main/java/whobot/main/WhoBot.java lines 83-87:

    /***
     * Main Method
     *
     * @param args Commandline arguments
     */

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 ๐Ÿ‘

โ„น๏ธ 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 [email protected] if you want to follow up on this post.

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

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/whobot/main/gui/DisplayBuffer.java lines 78-137:

    public static void printBuffer() {
        long delay = charCount > Gui.getShortTextLimit()
                ? Gui.getLongTextDelay()
                : Gui.getShortTextDelay();
        Thread printThread = new Thread(() -> {
            if (userInput != null && sendButton != null) {
                userInput.setDisable(true);
                sendButton.setDisable(true);
                int i = 0;
                if (!buffer.isEmpty()) {
                    int finalI = i;
                    Platform.runLater(() -> {
                        final Node node = BotDialogBox.getDialog(buffer.get(finalI), false, delay);
                        FadeTransition transition = new FadeTransition(Duration.millis(300), node);
                        transition.setFromValue(0);
                        transition.setToValue(1);
                        parent.getChildren().add(node);
                        transition.play();
                    });
                    try {
                        Thread.sleep(delay * buffer.get(i).length());
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    i++;
                }

                if (buffer.size() > 1) {
                    for (; i < buffer.size(); i++) {
                        int finalI1 = i;
                        Platform.runLater((() -> {
                            final Node node = BotDialogBox.getDialog(buffer.get(finalI1), true, delay);
                            FadeTransition transition = new FadeTransition(Duration.millis(300), node);
                            transition.setFromValue(0);
                            transition.setToValue(1);
                            parent.getChildren().add(node);
                            transition.play();
                            if (finalI1 == buffer.size() - 1) {
                                buffer.removeIf(c -> true);
                            }
                        }));
                        try {
                            Thread.sleep(delay * buffer.get(i).length());
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        if (buffer.size() == 0) {
                            userInput.setDisable(false);
                            sendButton.setDisable(false);
                        }
                    }
                } else {
                    buffer.removeIf(c -> true);
                    userInput.setDisable(false);
                    sendButton.setDisable(false);
                }
            }
        });
        printThread.start();
    }

Example from src/main/java/whobot/utils/Parser.java lines 27-106:

    public int parse(String command, UI ui, Storage storage, TaskList taskList) throws WhoBotException {

        assert ui != null;
        assert storage != null;
        assert taskList != null;

        Helper helper = new Helper(ui);

        if (command.isBlank()) {
            throw new WhoBotException("The input is blank. Please enter something.");
        }

        String[] commandList = command.toLowerCase(Locale.ROOT).split(" ");
        //All commands are taken as case-insensitive
        if (command.toLowerCase(Locale.ROOT).equals("bye") || command.toLowerCase(Locale.ROOT).equals("goodbye")) {
            // If input is bye or goodbye, quits program
            if (!WhoBot.isGui()) {
                ui.goodbye();
            }
            storage.saveMemory(taskList.getList());
            return -1;
        } else if (command.toLowerCase(Locale.ROOT).equals("list")) {
            // If input is list, prints list
            taskList.printList(ui);
        } else if (commandList[0].equals("help")) {
            // If input is list, prints list
            if (commandList.length == 1) {
                helper.showMainHelp();
            } else {
                helper.showCommandHelp(commandList[1]);
            }
        } else if (commandList.length == 2 && commandList[0].equals("done")) {
            //If input starts with done, mark the specific item in list as done
            taskList.markAsDone(commandList[1], ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList.length == 2 && commandList[0].equals("undo")) {
            //If input starts with undo, mark the specific item in list as not done
            taskList.markAsUndone(commandList[1], ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList.length == 2 && commandList[0].equals("delete")) {
            //If input starts with delete, delete the specific item in list
            taskList.deleteFromList(commandList[1], ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList[0].equals("todo")) {
            //If input starts with todos, add that to list
            taskList.addTodo(command, ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList[0].equals("event")) {
            //If input starts with event, add that to list
            taskList.addEvent(command, ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList[0].equals("deadline")) {
            //If input starts with deadline, add that to list
            taskList.addDeadline(command, ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList[0].equals("show")) {
            //If input starts with show, show tasks on specified date
            taskList.showOnDate(command, ui);
        } else if (commandList[0].equals("find")) {
            //If input starts with todos, add that to list
            taskList.findTask(command, ui);
        } else if (commandList[0].equals("tag")) {
            //If input starts with todos, add that to list
            taskList.tagTask(command, ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList[0].equals("untag")) {
            //If input starts with todos, add that to list
            taskList.untagTask(command, ui);
            storage.saveMemory(taskList.getList());
        } else if (commandList[0].equals("list")) {
            //If input starts with todos, add that to list
            taskList.listTagTask(command, ui);
            storage.saveMemory(taskList.getList());
        } else {
            // Else Invalid
            throw new WhoBotException("Oops, That's an invalid command."
                    + " Type in help to get list of possible commands.");
        }
        return 0;
    }

Example from src/main/java/whobot/utils/Storage.java lines 60-116:

    public void readData(ArrayList<Task> list, HashMap<String, ArrayList<Task>> taggedList) throws WhoBotException {
        try {
            Scanner taskReader = new Scanner(taskFile);
            while (taskReader.hasNextLine()) {
                String[] data = taskReader.nextLine().split(" \\| ");
                if (data[0].equals("T")) {
                    Todo tempTodo = new Todo(data[2]);
                    if (data[1].equals("X")) {
                        tempTodo.markAsDone();
                    }
                    if (data.length == 4) {
                        if (!taggedList.containsKey(data[3])) {
                            taggedList.put(data[3], new ArrayList<>());
                        }
                        taggedList.get(data[3]).add(tempTodo);
                        tempTodo.setTag(data[3]);
                    } else {
                        taggedList.get(NO_TAG).add(tempTodo);
                    }
                    list.add(tempTodo);
                } else if (data[0].equals("D")) {
                    Deadline tempDeadline = new Deadline(data[2]);
                    if (data[1].equals("X")) {
                        tempDeadline.markAsDone();
                    }
                    if (data.length == 4) {
                        if (!taggedList.containsKey(data[3])) {
                            taggedList.put(data[3], new ArrayList<>());
                        }
                        taggedList.get(data[3]).add(tempDeadline);
                        tempDeadline.setTag(data[3]);
                    } else {
                        taggedList.get(NO_TAG).add(tempDeadline);
                    }
                    list.add(tempDeadline);
                } else if (data[0].equals("E")) {
                    Event tempEvent = new Event(data[2]);
                    if (data[1].equals("X")) {
                        tempEvent.markAsDone();
                    }
                    if (data.length == 4) {
                        if (!taggedList.containsKey(data[3])) {
                            taggedList.put(data[3], new ArrayList<>());
                        }
                        taggedList.get(data[3]).add(tempEvent);
                        tempEvent.setTag(data[3]);
                    } else {
                        taggedList.get(NO_TAG).add(tempEvent);
                    }
                    list.add(tempEvent);
                }
            }
        } catch (FileNotFoundException e) {
            throw new WhoBotException("Oops, The file to store my data could not be created."
                    + " If you continue, tasks won't be stored permanently.");
        }
    }

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.

Aspect: Class size

No easy-to-detect issues ๐Ÿ‘

Aspect: Header Comments

Example from src/main/java/whobot/main/WhoBot.java lines 83-87:

    /***
     * Main Method
     *
     * @param args Commandline arguments
     */

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 ๐Ÿ‘

โ— 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 @nus-se-bot 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.