Coder Social home page Coder Social logo

ip's People

Contributors

damithc avatar j-lum avatar jiachen247 avatar vvidday avatar

ip's Issues

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

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

Example from src/main/java/ekud/util/ParseResult.java lines 4-4:

    public final boolean terminate;

Example from src/main/java/ekud/util/ParseResult.java lines 6-6:

    public final boolean saveStorage;

Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)

Aspect: Brace Style

Example from src/main/java/ekud/util/Parser.java lines 59-60:

        }
        else {

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/ekud/task/TaskList.java lines 151-198:

    private Task parseSpecialTask(String description, TaskType type) throws EkudException {
        Optional<Task> task = Optional.empty();
        String[] parts = description.split(" ");
        switch (type) {
        case TODO:
            if (parts.length < 2) {
                throw new EkudException("Description of a TODO cannot be empty.");
            }
            task = Optional.of(new ToDo(String.join(" ", Arrays.copyOfRange(parts, 1, parts.length))));
            break;
        case DEADLINE:
            // Fallthrough
        case EVENT:
            int idxOfSeparator = 0;
            for (int i = 0; i < parts.length; i++) {
                if (type == TaskType.EVENT && parts[i].equals("/at")) {
                    idxOfSeparator = i;
                } else if (type == TaskType.DEADLINE && parts[i].equals("/by")) {
                    idxOfSeparator = i;
                }
            }
            if (idxOfSeparator == 0) {
                String separator = type == TaskType.EVENT ? "/at" : "/by";
                throw new EkudException(
                        String.format("Invalid syntax. Use %s <task> %s <date/time>", type.toString(), separator));
            } else if (idxOfSeparator == 1) {
                throw new EkudException(String.format("Description of an %s cannot be empty.", type.toString()));
            } else if (idxOfSeparator == parts.length - 1) {
                throw new EkudException("Date/Time cannot be empty.");
            }
            String taskDesc = String.join(" ", Arrays.copyOfRange(parts, 1, idxOfSeparator));
            String taskDueDate = String.join(" ", Arrays.copyOfRange(parts, idxOfSeparator + 1, parts.length));
            if (type == TaskType.EVENT) {
                task = Optional.of(new Event(taskDesc, taskDueDate));
            } else {
                task = Optional.of(new Deadline(taskDesc, taskDueDate));
            }

            break;
        default:
            throw new EkudException("Invalid task type.");
        }
        if (task.isEmpty()) {
            throw new EkudException("Unexpected error.");
        } else {
            return task.get();
        }
    }

Example from src/main/java/ekud/util/Parser.java lines 29-63:

    public ParseResult parseCommand(String command, TaskList taskList, NoteList noteList) throws EkudException {
        String[] splitCommand = command.split(" ");
        String firstWord = splitCommand[0];
        if (command.equals("bye")) {
            return new ParseResult(true, "Bye. Hope to see you again soon!", false);
        } else if (command.equals("list")) {
            return new ParseResult(false, taskList.printTasks(), false);
        } else if (firstWord.equals("mark")) {
            return new ParseResult(false, taskList.markAsDone(command), true);
        } else if (firstWord.equals("unmark")) {
            return new ParseResult(false, taskList.markAsUndone(command), true);
        } else if (firstWord.equals("todo")) {
            return new ParseResult(false, taskList.addTask(command, TaskType.TODO), true);
        } else if (firstWord.equals("deadline")) {
            return new ParseResult(false, taskList.addTask(command, TaskType.DEADLINE), true);
        } else if (firstWord.equals("event")) {
            return new ParseResult(false, taskList.addTask(command, TaskType.EVENT), true);
        } else if (firstWord.equals("delete")) {
            return new ParseResult(false, taskList.deleteTask(command), true);
        } else if (firstWord.equals("find")) {
            return new ParseResult(false, taskList.searchTasks(
                    String.join(" ", Arrays.copyOfRange(splitCommand, 1, splitCommand.length))), false);
        } else if (firstWord.equals("note")) {
            return new ParseResult(false,
                    noteList.addNote(String.join(" ", Arrays.copyOfRange(splitCommand, 1, splitCommand.length))),
                    true);
        } else if (firstWord.equals("deletenote")) {
            return new ParseResult(false, noteList.deleteNote(command), true);
        } else if (firstWord.equals("listnote")) {
            return new ParseResult(false, noteList.printNotes(), false);
        }
        else {
            throw new EkudException("Invalid command.");
        }
    }

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/ekud/task/Task.java lines 50-55:

    /**
     * Get status icon of task.
     * 
     * @return Character representing the status of the task (whether it is done or
     *         not)
     */

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 @vvidday]

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

Example from src/main/java/ekud/util/ParseResult.java lines 4-4:

    public final boolean terminate;

Example from src/main/java/ekud/util/ParseResult.java lines 6-6:

    public final boolean saveStorage;

Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)

Aspect: Brace Style

Example from src/main/java/ekud/util/Parser.java lines 59-60:

        }
        else {

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/ekud/task/TaskList.java lines 151-198:

    private Task parseSpecialTask(String description, TaskType type) throws EkudException {
        Optional<Task> task = Optional.empty();
        String[] parts = description.split(" ");
        switch (type) {
        case TODO:
            if (parts.length < 2) {
                throw new EkudException("Description of a TODO cannot be empty.");
            }
            task = Optional.of(new ToDo(String.join(" ", Arrays.copyOfRange(parts, 1, parts.length))));
            break;
        case DEADLINE:
            // Fallthrough
        case EVENT:
            int idxOfSeparator = 0;
            for (int i = 0; i < parts.length; i++) {
                if (type == TaskType.EVENT && parts[i].equals("/at")) {
                    idxOfSeparator = i;
                } else if (type == TaskType.DEADLINE && parts[i].equals("/by")) {
                    idxOfSeparator = i;
                }
            }
            if (idxOfSeparator == 0) {
                String separator = type == TaskType.EVENT ? "/at" : "/by";
                throw new EkudException(
                        String.format("Invalid syntax. Use %s <task> %s <date/time>", type.toString(), separator));
            } else if (idxOfSeparator == 1) {
                throw new EkudException(String.format("Description of an %s cannot be empty.", type.toString()));
            } else if (idxOfSeparator == parts.length - 1) {
                throw new EkudException("Date/Time cannot be empty.");
            }
            String taskDesc = String.join(" ", Arrays.copyOfRange(parts, 1, idxOfSeparator));
            String taskDueDate = String.join(" ", Arrays.copyOfRange(parts, idxOfSeparator + 1, parts.length));
            if (type == TaskType.EVENT) {
                task = Optional.of(new Event(taskDesc, taskDueDate));
            } else {
                task = Optional.of(new Deadline(taskDesc, taskDueDate));
            }

            break;
        default:
            throw new EkudException("Invalid task type.");
        }
        if (task.isEmpty()) {
            throw new EkudException("Unexpected error.");
        } else {
            return task.get();
        }
    }

Example from src/main/java/ekud/util/Parser.java lines 29-63:

    public ParseResult parseCommand(String command, TaskList taskList, NoteList noteList) throws EkudException {
        String[] splitCommand = command.split(" ");
        String firstWord = splitCommand[0];
        if (command.equals("bye")) {
            return new ParseResult(true, "Bye. Hope to see you again soon!", false);
        } else if (command.equals("list")) {
            return new ParseResult(false, taskList.printTasks(), false);
        } else if (firstWord.equals("mark")) {
            return new ParseResult(false, taskList.markAsDone(command), true);
        } else if (firstWord.equals("unmark")) {
            return new ParseResult(false, taskList.markAsUndone(command), true);
        } else if (firstWord.equals("todo")) {
            return new ParseResult(false, taskList.addTask(command, TaskType.TODO), true);
        } else if (firstWord.equals("deadline")) {
            return new ParseResult(false, taskList.addTask(command, TaskType.DEADLINE), true);
        } else if (firstWord.equals("event")) {
            return new ParseResult(false, taskList.addTask(command, TaskType.EVENT), true);
        } else if (firstWord.equals("delete")) {
            return new ParseResult(false, taskList.deleteTask(command), true);
        } else if (firstWord.equals("find")) {
            return new ParseResult(false, taskList.searchTasks(
                    String.join(" ", Arrays.copyOfRange(splitCommand, 1, splitCommand.length))), false);
        } else if (firstWord.equals("note")) {
            return new ParseResult(false,
                    noteList.addNote(String.join(" ", Arrays.copyOfRange(splitCommand, 1, splitCommand.length))),
                    true);
        } else if (firstWord.equals("deletenote")) {
            return new ParseResult(false, noteList.deleteNote(command), true);
        } else if (firstWord.equals("listnote")) {
            return new ParseResult(false, noteList.printNotes(), false);
        }
        else {
            throw new EkudException("Invalid command.");
        }
    }

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/ekud/task/Task.java lines 50-55:

    /**
     * Get status icon of task.
     * 
     * @return Character representing the status of the task (whether it is done or
     *         not)
     */

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

โ„น๏ธ 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.